PowerShell for Windows Admins

Jun 23 2013   8:21AM GMT

Clearing Event logs



Posted by: Richard Siddaway
Tags:
Operating System
PowerShell

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

 Comment on this Post

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when other members comment.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to: