Skip to content

Instantly share code, notes, and snippets.

@Sam-Martin
Created May 27, 2015 10:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Sam-Martin/c7b02b3cb137899befd5 to your computer and use it in GitHub Desktop.
Save Sam-Martin/c7b02b3cb137899befd5 to your computer and use it in GitHub Desktop.
Parse default IIS log file in PowerShell
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