Share via


PowerShell View ULS Logs SharePoint 2013

Many times user gives a screenshot where we get:

  

As a SharePoint Admin, we have to look at the ULS logs. SharePoint ULS logs can be filtered using PowerShell and generate grid-view allows additional filtering. This can be handy to troubleshoot or search within ULS logs.

Script:



      if ((Get-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue) -eq $null) {     Add-PSSnapin "Microsoft.SharePoint.PowerShell" }  
              
      Get -SPLogEvent -StartTime "mm/dd/yyyy " -EndTime " mm/dd/yyyy" | out GridView  

Execution of the above PowerShell script opens a grid-view of the matching results. Grid-view has additional filtering capabilities.

Output can be written to a text file or log file using the following PowerShell command*:
*



      if ((Get-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue) -eq $null) {     Add-PSSnapin "Microsoft.SharePoint.PowerShell" }  
              
      Get -SPLogEvent -StartTime " mm/dd/yyyy" -EndTime " mm/dd/yyyy"  >> D:\output.txt  

* "Sorry, something went wrong” message with correlation ID can be filtered and written to a text file or log file:

*

if ((Get-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue) -eq $null) {     Add-PSSnapin "Microsoft.SharePoint.PowerShell" }
  
Get-splogevent | ?{$_.Correlation -eq "<Correlation ID>"} | select Area, Category, Level, EventID,Message | Format-List > D:\output.txt

Nice Article for checking ULS logs using powershell, but in the same time you can use Microsoft tool ULS log viewer tool, check below link

Microsoft ULS Log Viewer