Tuesday 1 July 2014

Retrieve SharePoint Log with Correlation ID using PowerShell

Very frequently we get Correlation ID in SharePoint 2013 with error page where we find "Sorry, something went wrong"

Now, to retrieve log from Log file (SharePoint Log File) either we commonly use ULS viewer or by going through SharePoint Log file  (Very Tedious task).

If we have the Correlation ID then we can easily retrieve the information using PowerShell cmdLet

get-splogevent | ?{$_.Correlation -eq "<Correlation ID>"} | select Area, Category, Level, EventID, Message | Format-List > C:\Awesome.log

in the above cmdLet "> C:\Awesome.log" will create a log file named as Awesome.log in c Drive.
Also please change "<Correlation ID>" with yours.

Updated Solution:
We can add start time (Time from when our log started)
get-splogevent -starttime (get-date).addminutes(-5) | ?{$_.Correlation -eq "<Correlation ID>"} | select Area, Category, Level, EventID, Message | Format-List > C:\Awesome.log

No comments :

Post a Comment