Created
May 27, 2015 10:50
-
-
Save Sam-Martin/c7b02b3cb137899befd5 to your computer and use it in GitHub Desktop.
Parse default IIS log file in PowerShell
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
gc "iislogfile.log" | %{ | |
$row = $_.split(' ') | |
New-Object psobject -Property @{ | |
# date time s-ip cs-method cs-uri-stem cs-uri-query s-port cs-username c-ip cs(User-Agent) cs(Referer) sc-status sc-substatus sc-win32-status time-taken OriginalIPAddress | |
DateCreated = Get-Date ($row[0] + ' ' + $row[1]) | |
"s-ip" = $row[2] | |
"cs-method" = $row[3] | |
"cs-uri-stem" = $row[4] | |
"cs-uri-query" = $row[5] | |
"s-port" = $row[6] | |
"cs-username" = $row[7] | |
"c-ip" = $row[8] | |
"cs(User-Agent)" = $row[9] | |
"cs(Referer)" = $row[10] | |
"sc-status" = $row[11] | |
"sc-substatus" = $row[12] | |
"sc-win32-status" = $row[13] | |
"time-taken" = $row[14] | |
"OriginalIPAddress" = $row[15] | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment