PowerShell: Search event log for text

Display Events with a particular Text

Administrators often have to stifle through Windows logs to troubleshoot problems with their systems or applications. However, manually going through heaps of system log information to find out the root cause of an event can be quite laborious.
 
However, with the help of the following PowerShell script, one can provide the text to search for as a parameter and display all the events that contain the text. 

Script

<#
.SYNOPSIS
This powershell script can be used to display events with a particular text.
.DESCRIPTION
This script can be used to display events with a particular text.
.EXAMPLE
C:\PS> C:\Script\Event_Log_Text.ps1 Bluetooth
Displays events containing bluetooth in its message.
#>
#Check if the event’s message matches with the given word.

param([String] $word)
Get-EventLog System | Where-Object { $_.Message -match $word }

 

Post navigation