Clearing Event logs

I needed to clear some event logs on a test machine. Rather than picking and choosing I’ll clear them all

Get-EventLog -List |
where {($_.Entries).Count -gt 0} |
foreach {Clear-EventLog -LogName $_.Log}

 

The interesting part is the where-object filter in that Entries is a collection of the Entries in the log. If you want the number of entries you have to specificaly ask for it. The output of get-eventlog –list is formatted to display the count

Published Sun, Jun 23 2013 15:19 by RichardSiddaway

Leave a Comment

(required) 
(required) 
(optional)
(required) 
If you can't read this number refresh your screen
Enter the numbers above: