Deprecated: strpos(): Passing null to parameter #1 ($haystack) of type string is deprecated in /www/collab365_296/public/wp-includes/functions.php on line 7025

Deprecated: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in /www/collab365_296/public/wp-includes/functions.php on line 2162

Deprecated: Hook imagify_allow_picture_tags_for_webp is deprecated since version 2.2! Use imagify_allow_picture_tags_for_nextgen instead. in /www/collab365_296/public/wp-includes/functions.php on line 5758
How to query the SharePoint ULS logs with Powershell - Collab365
Deprecated: strstr(): Passing null to parameter #1 ($haystack) of type string is deprecated in /www/collab365_296/public/wp-includes/functions.php on line 1145

Deprecated: stripos(): Passing null to parameter #1 ($haystack) of type string is deprecated in /www/collab365_296/public/wp-includes/functions.php on line 1152

Deprecated: stripos(): Passing null to parameter #1 ($haystack) of type string is deprecated in /www/collab365_296/public/wp-includes/functions.php on line 1155

Deprecated: strpos(): Passing null to parameter #1 ($haystack) of type string is deprecated in /www/collab365_296/public/wp-includes/functions.php on line 1162

Deprecated: strpos(): Passing null to parameter #1 ($haystack) of type string is deprecated in /www/collab365_296/public/wp-includes/functions.php on line 1165

Deprecated: strstr(): Passing null to parameter #1 ($haystack) of type string is deprecated in /www/collab365_296/public/wp-includes/functions.php on line 1145

Deprecated: stripos(): Passing null to parameter #1 ($haystack) of type string is deprecated in /www/collab365_296/public/wp-includes/functions.php on line 1152

Deprecated: stripos(): Passing null to parameter #1 ($haystack) of type string is deprecated in /www/collab365_296/public/wp-includes/functions.php on line 1155

Deprecated: strpos(): Passing null to parameter #1 ($haystack) of type string is deprecated in /www/collab365_296/public/wp-includes/functions.php on line 1162

Deprecated: strpos(): Passing null to parameter #1 ($haystack) of type string is deprecated in /www/collab365_296/public/wp-includes/functions.php on line 1165

Warning: Undefined array key "url" in /www/collab365_296/public/wp-content/plugins/thrive-visual-editor/thrive-dashboard/inc/smart-site/classes/class-tvd-smart-shortcodes.php on line 85

by Kushhh

2015-10-15

Did you know that the SharePoint ULS logs can be queried, filtered and output to a text file or GridView (allowing for  additional filtering).

This can be really handy to help troubleshoot problems, so this post offers 3 examples.

How to export ULS logs to a GridView for further filtering

Execution of the Powershell Script (below) will open a GridView showign the matching results. The GridView also has additional filtering capabilities allowing you to really target in on what you’re looking for.

Powershell script:

if ((Get-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue) -eq $null) 
{     
   Add-PSSnapin "Microsoft.SharePoint.PowerShell" 
}

Get -SPLogEvent -StartTime "10/15/2015 11:19" -EndTime "10/15/2015 11:20" | out GridView

Screenshot of the ULS Logs in a Powershell GridView:

How to export the ULS Logs to a text file

In the example blow, you will see how to query and output the ULS Logs to a text file.

Powershell script:

if ((Get-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue) -eq $null) 
{     
   Add-PSSnapin "Microsoft.SharePoint.PowerShell" 
}

Get -SPLogEvent -StartTime "10/15/2015 11:19" -EndTime "10/15/2015 11:20"  >> C:\ULSlogs.txt

How to search the ULS Logsfor a designated string

In this example, we show how you can search for text withing the Logs.

Powershell script:

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 > C:\ULSlogs.txt

 

(Visited 1,569 times, 1 visits today)

About the author 

Kushhh

Summit Bundle

Get 200+ hours of Microsoft 365 Training for 27$!

Master Office 365, Power Platform & SharePoint & Teams With 200+ Hours Of Training Videos and 108 Ebooks in the Collab365 Academy. This offer is insane and is only available for a limited period.