PowerTip: Clear All Events from Event Logs by Using PowerShell

PowerTip: Clear All Events from Event Logs by Using PowerShell

  • Comments 5
  • Likes

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.

Your comment has been posted.   Close
Thank you, your comment requires moderation so it may take a while to appear.   Close
Leave a Comment
  • What's the cmd to Save EventLog first?

  • @The Duder http://blogs.technet.com/b/heyscriptingguy/archive/2013/02/01/use-powershell-to-create-and-to-use-a-new-event-log.aspx

  • @The Duder http://blogs.technet.com/b/heyscriptingguy/archive/2013/02/01/use-powershell-to-create-and-to-use-a-new-event-log.aspx

  • My bad. ignore anonymous post

  • 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"