SharePoint: Find Error Details Based on Correlation ID using Powershell

Introduction to Problem

In SharePoint we generally see Correlation Id when we encounter any error during application. Here I will brief you about how to get the error details based on Correlation id using PowerShell.

Generally we go to 15 hive location to to access the latest log file and then find the error log for correlation Id or we use ULS log viewer to see the log details. To avoid this work a simple execution of command will give you all the error details for perticular correlation Id.

Syntax

  1. Get-SPLogEvent [-AssignmentCollection <SPAssignmentCollection>] [-AsString <SwitchParameter>] [-ContextKey <String[]>] [-Directory <String>] [-EndTime <DateTime>] [-MinimumLevel <String>] [-StartTime <DateTime>]   
Execute the command as shown below:

Get-SPLogEvent -StartTime (Get-Date).AddMinutes(-20) | ? { $_.Correlation -eq '{[Correlation ID]}'} | fl message > c:\errors.txt

Running this command will give you the results for error with Correlation ID mentioned in command for last 20 min.The result file will be placed at C:\Errors.txt.

Note: Replace the [Correlation ID] with Id received in error.

Reference

Get-SPLogEvent

Happy SharePointing!!!