PowerTip: Clear All Events from Event Logs by Using PowerShell


Summary: Use Windows PowerShell to clear all events from all event logs.

Hey, Scripting Guy! Question How can I use Windows PowerShell to clear all events from all traditional event logs to make it easier
          to find events when I am troubleshooting an intermittent issue on my server?

Hey, Scripting Guy! Answer Use the Get-EventLog cmdlet to retrieve a list of traditional event logs, and the Clear-EventLog cmdlet
          to clear the event logs:

Clear-EventLog -LogName (Get-EventLog -List).log –WhatIf

If this is what you want to do, remove the –WhatIf parameter:

Clear-EventLog -LogName (Get-EventLog -List).log

Note  You should consider backing up your event logs first.

Comments (7)

  1. The Duder says:

    What’s the cmd to Save EventLog first?

  2. Krunch {The Commenter formerly known as K} says:

    My bad. ignore anonymous post

  3. qMark says:

    How do I clear the rest of the eventlogs? The ones under "Applications and Services Logs". List them from a commandprompt with "wevtutil.exe el" or clear all logs with For /f "delims=," %i in ( ‘wevtutil el’ ) do wevtutil cl "%i"

  4. Slogmeister Extraordinaire says:

    This doesn’t work. It’s missing all the various logs under the "Applications and Services Logs" folder.

  5. ARiel says:

    is not a good option in windows 2k8 , but this dont clear all events logs.
    use wevevtutil to a total clear.
    see this link http://jpwaldin.com/blog/?p=166

Skip to main content