Today I would like to share with you an useful script to help on troubleshooting errors using PowerShell in SharePoint when some unexpected exception happens . This script can help you on tracing the exact cause of a bug in the application while relieving you from opening the entire log file and search for the error message in a not so productive way.

The SharePoint logs folder - Troubleshooting errors using Powershell in SharePoint
The SharePoint logs folder (Microsoft docs)

These logs are written by SharePoint and according to Microsoft, this is what you get from it:

“The Unified Logging Service (ULS) is the service that is responsible for keeping an eye on SharePoint and reporting what it finds. It can report events to three different locations:

  • SharePoint trace logs
  • Windows Event Log
  • SharePoint logging database

Where the event is logged (and if it’s logged at all) depends on the type of event, as well as how SharePoint is configured. The ULS is a passive service, which means that it only watches SharePoint and reports on it; it never acts on what it sees.”

Continue reading