Title: Get the hits from IIS logs who accessed the Myname.aspx page
Description: Get all usernames who accesses the selected page. find based on keyword.
Description: Get all usernames who accesses the selected page. find based on keyword.
- ##################################################################################
- # Written by : Bramhendra Lakku
- # Approved by:
- # Script name: hits.ps1
- # Purpose: Get the search key words#
- # Company:
- # Input Parameters Format for report :N/A
- # Out Put: Output file will generated in this Folder
- ##################################################################################
- # run with Farm admin account or provide the permissions to your account Go to Central Administration => Application Management => Manage Service Applications => User Profile Service Application.Click on Administrators => Add the user and give Full Control.
- #Click on Permissions => Add the user and give Full Control.
- $date = Get-date -format "MMddyyy-hhmmss"
- $OutPutFilename="Links-19-edit-$date.csv";
- "Login ID" + "," +"Date(YYYY-MM-DD)" | Out-File -Encoding Default -FilePath $OutPutFilename;
- function Get-DataByInput ($path, $id1, $id2)
- {
- $dataRegex = "$id1"
- $dataRegex1 = "$id2(.+)$"
- Get-Content $path | % {
- if ($_ -match $dataRegex )
- {
- if ($_ -match $dataRegex1 )
- {
- $Did=$matches[1];
- $dateprint = $_.Substring(0,10) #adjest number
- #write-host $dateprint
- $Didname=$Did.Split(' ')[0].Replace("\","")
- #write-host $Did.Split(' ')[0] "#########" $SearchKeyWord.Split(' ')[0]
- $Didname + ", " +$dateprint | Out-File -Encoding Default -Append -FilePath $OutPutFilename;
- }
- }
- }
- }
- Get-ChildItem "E:\LogLocation" –Recurse -Filter *.log |
- Foreach-Object {
- # Make sure to include https and http requests
- Get-DataByInput -path $_.FullName -id1 "Myname.aspx" -id2 "domainname"
- #write-host $_.FullName
- }