February 1st, 2014

PowerTip: Clear All Events from Event Logs by Using PowerShell

Doctor Scripto
Scripter

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.

Author

The "Scripting Guys" is a historical title passed from scripter to scripter. The current revision has morphed into our good friend Doctor Scripto who has been with us since the very beginning.

0 comments

Discussion are closed.

Feedback