Windows 7 Forums
Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.


Windows 7: Event Viewer: Clear All Events



Event Viewer: Clear All Events

How to Clear all Event Logs in Event Viewer using Windows PowerShell
Published by Slartybart
31 Jan 2014
Published by

How to Clear all Event Logs in Event Viewer using Windows PowerShell

information   Information
This tutorial will show you how to quickly clear all event logs in Event Viewer with a one line PowerShell script.

This one line command clears each log in the Event log list one at a time.
wevtutil el gets the Event log list and passes the list to
Foreach-Object which calls
wevtutil cl for each log in the Event log list.

Note   Note
This process does not clear Analytic or Debug logs. If you have them enabled, wevutl returns an error, but the other logs are cleared.

warning   Warning
If you are trouble shooting an issue on your computer it is NOT advisable to clear the Event logs. The Event logs provide technical information about your system that could help resolve an issue.
Only clear the Event logs if your system is running well. The logs don't use a lot of resources so it doesn't hurt to leave them in place.


Here's How:

1. Open an elevated PowerShell prompt.

2. Copy and paste the command below into the PowerShell window, and press Enter.
wevtutil el | Foreach-Object {wevtutil cl "$_"}
Name:  EventViewer_PScmd.png
Views: 4208
Size:  21.2 KB
4. Wait for the script to finish, then you can close PowerShell if you like.

5. All events have been cleared.


This tutorial showed you how to clear all logs in Event Viewer, but you can use the wevtutil command to clear individual event logs.
Instead of using the el parameter and piping the list to Foreach-Object, you would use the cl parameter and the log name.

Copy the line following the specific event log and paste the wevtutil line (the bold line) into the PowerShell window.


To clear the
  • Application event log
    wevtutil cl Application

  • Security event log
    wevtutil cl Security

  • Setup event log
    wevtutil cl Setup

  • System event log
    wevtutil cl System
You can clear any of the Event logs the same way, all you have to know is the log name.
To get a full list of the log names, simply enter wevtutil el in the elevated PowerShell window.

Then you can use the cl parameter and the event log name to clear that specific event log (see the examples above).

Note   Note
There are two command parameters of wevtutil used in this section:
cl is the clear event log parameter
el is the event log list parameter

The results will be quite different if you use the wrong one. For any clear the log operation in this section, you will use the cl parameter.

Tip   Tip
While unrelated to clearing Event Viewer logs, this tip does clean up one particular event. WMI error 10 is erroneoulsy logged in the application log after every reboot.
This is easy to fix with MS Fixit 50688 - scroll down on the MS Fixit page and click the Microsoft Fix it button.



Credits:
Joe Waldin: script source
Brink: tutorial housekeeping




16 Feb 2014   #1
DavidW7ncus

Win 7 Pro x64 SP1, Win 7 Ult x86 SP1
 
 

Nice tutorial!
Does clearing event logs make a noticeable performance improvement or a significant decrease in space used on the C drive?
My OSs were installed 4+ years ago and I've never cleared logs.

Thanks,
David

My System SpecsSystem Spec
16 Feb 2014   #2
Brink
Microsoft MVP

64-bit Windows 8.1 Enterprise
 
 

Hey David,

It makes no difference in performance, and not much hard drive space would be regained. It's mostly just if you wanted to clear the logs.
My System SpecsSystem Spec
16 Feb 2014   #3
DavidW7ncus

Win 7 Pro x64 SP1, Win 7 Ult x86 SP1
 
 

Thanks Shawn
My System SpecsSystem Spec
.


16 Feb 2014   #4
Brink
Microsoft MVP

64-bit Windows 8.1 Enterprise
 
 

Your welcome.
My System SpecsSystem Spec
17 Feb 2014   #5
Slartybart

x64 (6.3.9600) Win8.1 Pro & soon dual boot x64 (6.1.7601) Win7_SP1 HomePrem
 
 

Thanks David,

Shawn is right... no performance boost or even significant space reclamation.

Reading logs is an art - clearing the logs simply removes ancient history. The MS Fixit tip at the bottom is probably more important to me because it stops a bogus error log so I don't have to think "Hey there's an error.... is it important? Nah, it's just that WMI 10 log entry..." The entries for WMI 10 are still there until you clear the event logs.

The real trick is NOT clearing the logs too often - you might lose that key piece of information.

Rule of thumb: if your system is stable and has been for a while - clear the logs. In a year or two, same conditions, clear the logs again. This really isn't something you have to do on a regular basis.

Bill
.
My System SpecsSystem Spec
17 Feb 2014   #6
DavidW7ncus

Win 7 Pro x64 SP1, Win 7 Ult x86 SP1
 
 

Thanks for the info.
My systems are stable. No problems with updates, no crashes, etc.
I just know as soon as I clear the logs something will happen, and I'll wish I had the history.
My System SpecsSystem Spec
28 May 2014   #7
giblet

Windows 7 Ultimate 64bit
 
 
BAT file for lazy people...

@echo off
FOR /F "tokens=1,2*" %%V IN ('bcdedit') DO SET adminTest=%%V
IF (%adminTest%)==(Access) goto noAdmin
for /F "tokens=*" %%G in ('wevtutil.exe el') DO (call :do_clear "%%G")
echo.
echo goto theEnd
:do_clear
echo clearing %1
wevtutil.exe cl %1
goto :eof
:noAdmin
exit


Copy to Notepad and save as *.BAT

Double click to run BAT files.

All logs cleared.
My System SpecsSystem Spec
28 May 2014   #8
Slartybart

x64 (6.3.9600) Win8.1 Pro & soon dual boot x64 (6.1.7601) Win7_SP1 HomePrem
 
 

giblet, see the related tutorial for the Command Prompt version. This tutorial is a Powershell script.
Event Viewer One Click Clear
My System SpecsSystem Spec
Comment

 Event Viewer: Clear All Events




Tutorial Tools



Similar help and support threads for2: Event Viewer: Clear All Events
Windows 7 Tutorial Category
Event Viewer One Click Clear Tutorials
Solved 45,120 events in event viewer, I have a keylogger System Security
Why is event viewer not logging some events General Discussion
How To Clear Administrative Events Log - Event Viewer Performance & Maintenance
How to clear events in viewer? General Discussion

Our Sites

Site Links

About Us

Find Us

Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

Designer Media Ltd

All times are GMT -5. The time now is 08:20 PM.
Twitter Facebook Google+



Windows 7 Forums

Seven Forums Android App Seven Forums IOS App
  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33