Clear event logs with powershell

Clear event logs with powershell

In this very quick article I will show you how to clear event logs with powershell. I will also cover how to clear all even logs. First of all, you will need to run PowerShell as an administrator. If you’re not the local admin for the machine you’re trying to clear the even logs for, then it won’t work.

Let’s start with getting the event log name that you want to clear, the command below will give you a list of logs available:

wevtutil el

You’ll get a (very) long list with all of the event logs:

wevtutil el

In this example I will clear all of the events in HardwareEvents:

wevtutil cl HardwareEvents

Very simple! Now let’s finaly see how to clear all of the event logs.

wevtutil el | Foreach-Object {wevtutil cl "$_"}

As you can see I’m firstly passing all of the event logs (with wevtutil el) on a foreach object and, for each event, I run wevtutil with the cl (clear logs) option we’ve seen above. That’s it! This is how you clear event logs with powershell!

IT Droplets

IT Droplets