Displaying the Windows Event Log with PowerShell

The latest post in the  PowerShell Box of tricks series is here.

I’ll start by saying this is a bit of a cheat. PowerShell has a perfectly good cmdlet called Get-EventLog and plenty of ways to use it

I created this function because I like to use Out-GridView and specify only a few records so it is quicker on remote systems. I like Out-GridView as it enables me to filter easily by typing in the top box. This is most often used via the simple GUI I have created. At the command line I would just use Get-EventLog

image

The function is shown below. It is important to know that the $log parameter is CaSeSensItive

image

The Code is here

#####################################################################
#
# NAME: Show-EventLog.ps1
# AUTHOR: Rob Sewell http://newsqldbawiththebeard.wordpress.com
# DATE:06/08/2013
#
# COMMENTS: Load function for Showing the windows event logs on a server
# ————————————————————————
# Define a server an event log the number of events and display
# pipe to this and then to out-gridview to only show Errors -      where {$_.entryType -match "Error"}

Function Show-EventLog ($Server, $log, $Latest) {

    Get-EventLog  -computername $server -log $log -newest $latest | Out-GridView
}