While the graphical Event Viewer snap-in (eventvwr.msc) is familiar to most Windows administrators, navigating through nested management trees to inspect and filter thousands of system, security, or application events across remote servers or automated recovery scripts can be slow and resource-heavy. For system administrators, DevOps engineers, and support technicians, Windows includes a native command-line utility designed for low-level log management: wevtutil.exe (Windows Event Utility). Operating directly against Windows XML Event Log channels (.evtx), this tool enables rapid querying, granular XPath filtering, automated log exporting, and administrative log clearance.
Mastering wevtutil commands allows you to automate forensic log archiving, troubleshoot intermittent system errors, and maintain system disk storage directly from Command Prompt or PowerShell.
Overview of wevtutil Capabilities and Common Use Cases
The wevtutil utility interacts with the Windows Event Log service directly, providing capabilities beyond standard graphical viewers:
- High-Speed XPath Filtering: Query specific event IDs, severity levels, or timeframes without waiting for graphical interface caching.
- Forensic Log Archiving: Export entire channels or filtered query results to standalone
.evtxfiles for offline analysis and auditing. - Channel Property Auditing: Inspect buffer sizes, retention policies, and file storage locations for over a thousand registered system event logs.
- Automated Maintenance: Clear clogged or obsolete event logs with single-line scripts during deployment preparation or maintenance windows.
Listing Available Event Log Channels
Modern Windows operating systems register hundreds of specialized subsystem channels in addition to standard administrative logs:
- Right-click the Start button and select Terminal (Admin) or Command Prompt (Run as Administrator).
- To view all registered event log channels on the system:
wevtutil enum-logs
- To inspect the current configuration and size of a core channel (for example, the System log):
wevtutil get-log System
- The output displays key metrics including maximum log file size in bytes, retention behavior (circular overwriting vs archiving), and operational status.
Querying Specific Event Records via the Command Line
To inspect active issues on a workstation without launching the GUI:
- Retrieve the 10 most recent error events from the System log, rendered in reverse chronological order as human-readable plain text:
wevtutil qe System "/q:*[System[(Level=2)]]" /c:10 /rd:true /f:text
- Examine the syntax flags used in this query:
qe: Instructs the utility to query events./q: Specifies an XPath structured query filter. In the Windows event schema,Level=1indicates Critical,Level=2indicates Error,Level=3indicates Warning, andLevel=4indicates Informational./c:10: Limits output to a maximum count of 10 events./rd:true: Reads events in reverse direction (most recent first)./f:text: Formats XML payloads into structured plain text.
- To query events matching a specific Event ID (for example, Event ID 41 representing unexpected kernel power loss):
wevtutil qe System "/q:*[System[(EventID=41)]]" /c:5 /rd:true /f:text
Exporting and Archiving Event Logs to .evtx Files
Before purging event histories or migrating logs to external storage, export the raw events to preserve cryptographic integrity:
- Export the entire Security event channel into a standalone backup file:
wevtutil export-log Security "C:BackupsSecurityLog_Archive.evtx"
- To export only a filtered subset of events (such as successful user logon events matching ID 4624):
wevtutil export-log Security "C:BackupsUserLogons.evtx" "/q:*[System[(EventID=4624)]]"
Safely Clearing Individual and Batch Event Logs
Clearing log channels requires elevated administrative privileges:
- To clear a specific channel while automatically generating a safety backup archive:
wevtutil clear-log Application /bu:"C:BackupsApplication_SafetyBackup.evtx"
- To clear a channel immediately without creating a backup:
wevtutil clear-log System
- To batch-clear all populated event logs across the entire system during automated PC refurbishment, run this PowerShell pipeline:
Get-WinEvent -ListLog * -Force | Where-Object { $_.RecordCount -gt 0 } | ForEach-Object { wevtutil cl $_.LogName }