Skip to main content

PowerShell script to clear all Windows Event Logs. Clearing all of the Windows Event Logs is useful in development environments (for example, to check if a computer reboots "cleanly" -- i.e. without any errors).

<#
.SYNOPSIS
Clears all Windows event logs.

.DESCRIPTION
Clearing all of the Windows event logs is useful in development environments
(for example, to check if a computer reboots "cleanly" -- i.e. without any
errors).

.EXAMPLE
.\Clear-EventLogs.ps1

.NOTES
This script must be run with administrator privileges.
#>

#Set-StrictMode -Version Latest
#$ErrorActionPreference = "Stop"
#wevtutil el | ForEach-Object { wevtutil cl $_ }

# proper... see: http://serverfault.com/a/460863
Get-WinEvent -ListLog Application,Setup,Security,System,"Windows PowerShell" -Force | % { Wevtutil.exe cl $_.Logname }