IIS Logs

Blah

Parse IIS Logs

$inputFile = "C:\logs\blah.log" $filter = "*username*" $header = Get-Content $inputFile | select -First 5 | where {$_ -like "#Fields*"} $header = $header.trim() $header = $header.Replace("#Fields: ","") $header = $header.split(" ") $Data = Get-content $inputfile | where {$_ -like $filter} | ConvertFrom-Csv -Delimiter " " -Header $header $data | select date, time, @{Name="Adjusted Date"; Expression = {$(Get-Date $($_.date + " " + $_.Time)).addhours(-8) | Get-Date -uformat "%Y-%m-%d %T"}} 

Much simplified version :) from google search

get-content LogFile.log |%{$_ -replace '#Fields: ', ''} |?{$_ -notmatch '^#'} | ConvertFrom-Csv -Delimiter ' '