12-06-2010
Downloads: 579
File size: 592 B
Views: 2,627
Embed
 |
Read all Event Logs in one step |
-
-
-
- $from = (Get-Date) - (New-Timespan -hour 1)
-
- get-eventlog -List |
- Select-Object -ExpandProperty Log |
- Foreach-Object { Write-Progress 'Examining Eventlog' $_; $_} |
- Foreach-Object {$log = $_;
- try { Get-EventLog -after $from -LogName $log -ea stop |
- Add-Member NoteProperty EventLog $log -pass }
- catch { Write-Warning "Unable to access $log : $_"} } |
- Sort-Object TimeGenerated -desc |
- Select-Object EventLog, TimeGenerated, EntryType, Source, Message |
- Format-Table -Auto
Demonstrates how to query which event logs exist and then query all of them for all events that occured within the past hour. Code incorporates simple error handling, a progress bar and adding the original event log name to the entry properties so you know where the events originally came from.