Windows OS Hub
  • Windows
    • Windows 11
    • Windows Server 2022
    • Windows 10
    • Windows Server 2019
    • Windows Server 2016
  • Microsoft
    • Active Directory (AD DS)
    • Group Policies (GPOs)
    • Exchange Server
    • Azure and Microsoft 365
    • Microsoft Office
  • Virtualization
    • VMware
    • Hyper-V
  • PowerShell
  • Linux
  • Home
  • About

Windows OS Hub

  • Windows
    • Windows 11
    • Windows Server 2022
    • Windows 10
    • Windows Server 2019
    • Windows Server 2016
  • Microsoft
    • Active Directory (AD DS)
    • Group Policies (GPOs)
    • Exchange Server
    • Azure and Microsoft 365
    • Microsoft Office
  • Virtualization
    • VMware
    • Hyper-V
  • PowerShell
  • Linux

 Windows OS Hub / Windows 10 / How to Clear Event Viewer Logs on Windows

November 9, 2023

How to Clear Event Viewer Logs on Windows

On Windows, you can clear Event Viewer logs by using the eventvwr.msc GUI snap-in, from the command prompt, and by using PowerShell.

Contents:
  • Delete Saved Windows Logs Using the Event Viewer GUI
  • How to Clear Windows Event Logs from Command Prompt
  • Clear-EventLog: Clearing Event Viewer Logs with PowerShell

Delete Saved Windows Logs Using the Event Viewer GUI

The most intuitive way to clear your Windows event logs is to use the Event Viewer graphical console.

  1. Open the Event Viewer MMC snap-in eventvwr.msc;
  2. Right-click on the log name and select Clear Log.event viewer clear log from GUI

You can use this method to quickly delete all of the events from a particular log.

By default, Windows stores log files with an EVTX extension in the %SystemRoot%\System32\Winevt\Logs\ directory.

EVTX log files on windows %\System32\Winevt\Logs\ directory

There are hundreds of event log files that are used on Windows by various components of the operating system and third-party software. If you need to clear them all, it will be tedious to manually click through all the Event Viewer sections and purge each log. In this case, it is better to use PowerShell or the command line to clear the events.

How to Clear Windows Event Logs from Command Prompt

You can use the wevtutil.exe console tool to clear Windows logs from the command prompt.

List the Event Viewer logs registered in Windows:

WevtUtil enum-logs

or use a shorter version:

WevtUtil el

To delete all events from a particular log, copy the name of the log and run the command:

WevtUtil cl Microsoft-Windows-GroupPolicy/Operational

Before cleaning, you can back up the log events to a separate file:

WevtUtil cl Microsoft-Windows-GroupPolicy/Operational /bu:GPOLOG_Bak.evtx

You can clear all Event Viewer logs from cmd.exe at once:

for /F "tokens=*" %1 in ('wevtutil.exe el') DO wevtutil.exe cl "%1"

For a BAT file, you need to use a slightly different syntax:

for /F "tokens=*" %%1 in ('wevtutil.exe el') DO wevtutil.exe cl "%%1"

Clear-EventLog: Clearing Event Viewer Logs with PowerShell

You can use the Get-WinEvent and Clear-EventLog PowerShell cmdlets to list and clear Windows event logs.

Open a PowerShell console as an administrator, list all log names in Windows and their settings:

Get-WinEvent -ListLog *

Get-WinEvent: list windows event viewer logs

This command displays the maximum sizes and settings of all Event Viewer logs in Windows.

To delete all the events from two event logs (for example, from Security and System logs), run the following command:

Clear-EventLog –LogName Security,System

In this case, the log is cleared and the entry with EventID 104 or 1102 appears with the time of clearing, the user who performed it, and a event description:

The System log file was cleared.
The audit log was cleared.

Clear-EventLog –LogName System The System log file was cleared

To clear administrative and operational event logs in Windows, run the following PowerShell one-liner command:

Get-WinEvent -ListLog * -Force | % { Wevtutil.exe cl $_.Logname }

or:

wevtutil el | Foreach-Object {wevtutil cl "$_"}

Note. In this example, 3 event logs could not be cleared due to an access denied error. Try clearing these logs manually from the Event Viewer snap-in.

clear all logs at once

1 comment
7
Facebook Twitter Google + Pinterest
PowerShellWindows 10Windows 11Windows Server 2019
previous post
Recovering Files from a RAW Partition using TestDisk
next post
How to Obtain SeDebugPrivilege when Debug Program Policy is Enabled

Related Reading

How to increase KMS current count (count is...

March 12, 2024

Auto-mount VHD/VHDX File at Startup in Windows

February 20, 2024

Error 0x0000007e: Windows cannot connect to network printer,...

March 11, 2024

Removable USB Flash Drive as Local HDD in...

March 11, 2024

Booting Windows from GPT Disk on BIOS (non-UEFI)...

March 11, 2024

Recovering Files from a RAW Partition using TestDisk

March 16, 2024

Fix: Limited Wi-Fi Access in Windows

March 11, 2024

How to Configure and Deploy Screensaver on Windows...

December 8, 2023

1 comment

bobby April 3, 2023 - 8:51 pm

Very good guide for managing LOG files.

Reply

Leave a Comment Cancel Reply

join us telegram channel https://t.me/woshub
Join WindowsHub Telegram channel to get the latest updates!

Recent Posts

  • Map a Network Drive over SSH (SSHFS) in Windows

    May 13, 2025
  • Configure NTP Time Source for Active Directory Domain

    May 6, 2025
  • Cannot Install Network Adapter Drivers on Windows Server

    April 29, 2025
  • Change BIOS from Legacy to UEFI without Reinstalling Windows

    April 21, 2025
  • How to Prefer IPv4 over IPv6 in Windows Networks

    April 9, 2025
  • Load Drivers from WinPE or Recovery CMD

    March 26, 2025
  • How to Block Common (Weak) Passwords in Active Directory

    March 25, 2025
  • Fix: The referenced assembly could not be found error (0x80073701) on Windows

    March 17, 2025
  • Exclude a Specific User or Computer from Group Policy

    March 12, 2025
  • AD Domain Join: Computer Account Re-use Blocked

    March 11, 2025

Follow us

  • Facebook
  • Twitter
  • Telegram
Popular Posts
  • How to Get My Public IP Address with PowerShell
  • How to See Number of Active User Sessions on IIS WebSite
  • How To Monitor Group Membership Changes in Active Directory
  • How to Connect and Query MySQL or MariaDB with PowerShell
  • Windows: Auto Reconnect to VPN on Disconnect
  • PowerShell Remoting via WinRM for Non-Admin Users
Footer Logo

@2014 - 2024 - Windows OS Hub. All about operating systems for sysadmins


Back To Top