dinsdag 22 januari 2013

Read ULS log with powrshell


When solving issues on a SharePoint environment. You need a lot of times take a look at the ULS logs of SharePoint. Instead of logging in on a remote desktop connection (RDC) you can create a file share of the log files folder of SharePoint.

With the next PowerShell script you can read the uls logs via the file share based on your Correlation ID.



Function Get-ULSLog ($correlationid, $timelimit = 30) {
                @("Server 1","Server 2","Server 3") |
                % {gci "\\$_\Name of the file share\*.log"} |
                ? { $_.LastWriteTime -gt (Get-Date).AddMinutes(-$timelimit)} | 
                import-csv -delim "`t" | ? {$_.Correlation -match $correlationid}
}


Get-ULSLog "Correlation ID" 30



Have fun, it will save a lot of time.

Geen opmerkingen: