Advertisement
PtiTom

IIS Log File extraction

Mar 20th, 2015
362
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $MaxDelay = 5000
  2. $TimeoutDelay = 30000
  3.  
  4. $IISLogPath = "FullLogPath"
  5. $IISLogFileRaw = [System.IO.File]::ReadAllLines($IISLogPath)
  6. $headers = $IISLogFileRaw[3].split(" ".ToCharArray(), [System.StringSplitOptions]::RemoveEmptyEntries)
  7. $headers = $headers | where {$_ -ne "#Fields:"}
  8. $IISLogFileCSV = Import-Csv -Delimiter " " -Header $headers -Path $IISLogPath
  9. $IISLogFileCSV = $IISLogFileCSV | where {$_.date -notlike "#*"}
  10. $timeTaken = $IISLogFileCSV | foreach {$_.$("time-taken")}
  11. $IISLogFileCSV | where {[int]$_.$("time-taken") -gt $MaxDelay} | Format-Table -AutoSize time, cs-username, cs-uri-stem, time-taken, sc-bytes
  12. $IISLogFileCSV | where {[int]$_.$("time-taken") -gt $TimeoutDelay} | Format-Table -AutoSize time, cs-username, cs-uri-stem, time-taken, sc-bytes
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement