Clear Windows Event Logs via PowerShell

Description

This PowerShell script clears specified event logs or all logs if * is provided as input.

Overview

The script takes a list of event log names and clears their contents using Clear-EventLog. If * is provided, it dynamically retrieves all available event logs on the system and clears them.

By default, it targets the following logs:

  • Security
  • Application
  • System
  • Microsoft-Windows-PowerShell/Operational
  • Windows PowerShell
  • Microsoft-Windows-Security-Auditing
  • Microsoft-Windows-Sysmon/Operational

Each log is processed in a loop, and its contents are cleared. This script is useful for forensic countermeasures or log maintenance but requires administrative privileges to execute successfully.

Parameters

Name Type Description
Logs string[] A list of event logs to clear, or * to clear all logs. Defaults to a predefined set of logs.
Scroll to Top