Created
January 14, 2020 12:39
-
-
Save joe-scalise/d059e0323eaf84b0d8d17762b6556103 to your computer and use it in GitHub Desktop.
Use PowerShell to Parse IIS Logs for String
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $logPath = "C:\inetpub\logs\LogFiles\W3SVC1\" | |
| $logFiles = [System.IO.Directory]::GetFiles($logPath, "*.log") | |
| # $logs will store each line of the log files in an array | |
| $logs = @() | |
| # Skip the comment lines | |
| $logFiles | % { Get-Content $_ | where {$_ -notLike "#[D,F,S,V]*" } | % { $logs += $_ } } | |
| # Example search for HTTP 500 | |
| $logs | Select-String -Pattern '500' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment