Clear All Event Logs with PowerShell

I had a situation where I needed to clear all of the event logs on a 2008R2 Windows Server. I launched the event viewer and was going to manually clear each of the logs.

Yikes! There are 394 event logs on my server. No way am I going to do this manually. This is a job for PowerShell.

To clear all of the event logs, run PowerShell as an administrator and type in the following command text…

ClearEventLogs

That’s it. Remember that this command will clear ALL event logs. If you want to clear an individual log (Application log for example) use this…

If you want to get a list of all the event logs on your server use this…

It will provide you with a list similar to this…

ClearEventLogs2

Don’t forget to run PowerShell as an administrator.

 

This entry was posted in PowerShell. Bookmark the permalink.