PowerShell script to clear all event logs in Windows

Hi Friends,

Here is a powerful powershell script to clear all event logs in windows. Please run in test environment before you decide to use it any further 🙂

Execute this and watch the fun:

   

wevtutil el | Foreach-Object {Write-Host “Clearing $_”; wevtutil cl “$_”}

PS: The above needs to be executed in Powershell command prompt; Start -> Run -> powershell

 

 

   

About Amit Bansal

Amit Bansal is always brainstorming around SQL Server. Despite working with SQL since 1997, he is amazed that he keeps learning new things every single day. SQL Server is AB's first love, and his wife does not mind that. He tries to share as much and spreads the SQL goodness. Internals and Performance Tuning excites him, and also gives him sleepless nights at times, simply because he is not a genius, but quite a hard worker and does not give up. It has been a long and exciting journey since 1997, you can read here: http://sqlmaestros.com/amit-bansal/ He is on Twitter: https://www.twitter.com/A_Bansal

View all posts by Amit Bansal →

One Comment on “PowerShell script to clear all event logs in Windows”

  1. Hey Amit,

    Tryto use the native cmdlet Clear-Eventlog :

    Clear-eventlog -logname application or

    Clear-eventlog -logname security -computername RemoteComputer or

    Clear-EventLog -logname application -whatif to see before happens

    try get-help Clear-Eventlog -full to a complete help to the cmdlet

    🙂

Leave a Reply

Your email address will not be published.