Look at remote event log

This script will look in the Security EventLog at machinename
for EventId 680 and display the last 5.
$logs=[System.Diagnostics.EventLog]::GetEventlogs("machinename")
$app = $logs |? {$_.log -eq 'security'}
$myError = $app.entries | ? {$_.eventid -eq '680'}
$myError | Select-Object -Last 5
To look at the whole security log you can do like this:
$logs=[System.Diagnostics.EventLog]::GetEventlogs("machinename")
$app = $logs |? {$_.log -eq 'security'}
$app.entries
Last 10 events from the security log
$logs=[System.Diagnostics.EventLog]::GetEventlogs("machinename")
$app = $logs |? {$_.log -eq 'security'}
$app.entries | Select-ObjectLast 10
 
Technorati Tags: ,,
This entry was posted in PowerShell Blogs and tagged , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>