How to clear Windows event logs using command line?

Solution 1:

Powershell.

PS C:\>Clear-Eventlog -Log Application, System

The default is not to prompt you, but you can supply the -Confirm switch if you want to be prompted.

Edit:

Get-WinEvent -ListLog Application,Setup,Security -Force | % { Wevtutil.exe cl $_.Logname }

As per the comments, that should get both Operational and Administrative logs.

Solution 2:

wevtutil enum-logs will enumerate all logs in the system while wevtutil clear-log will clear the logs. For your case it would be:

wevtutil clear-log Application
wevtutil clear-log Security
wevtutil clear-log Setup
wevtutil clear-log System

You can also backup while clearing with wevtutil clear-log System /backup:backup.evtx

Solution 3:

For the case you want to clear all logs:

for /f %x in ('wevtutil el') do wevtutil cl "%x"

Extracted from here.