Filter Windows Event Logs with Get-WinEvent -FilterHashtable

Query System, Application, or Security logs for recent errors using FilterHashtable — far faster than piping Get-EventLog through Where-Object.

Windowstroubleshootingpowershellevent-logLow risk
Run Get-WinEvent -FilterHashtable @{LogName='System'; Level=2; StartTime=(Get-Date).AddDays(-7)} to get the last week's error events.

01Command

Command
$ Get-WinEvent -FilterHashtable @{LogName='System'; Level=2; StartTime=(Get-Date).AddDays(-7)} -MaxEvents 20 | Format-Table TimeCreated, Id, ProviderName, Message -AutoSize

02What it does

-FilterHashtable pushes the filter into the Windows Eventing engine, so it reads only matching records, while `Get-EventLog | Where-Object` deserializes every event first and crawls on large logs. Level 2 = Error, 3 = Warning, 1 = Critical; StartTime/EndTime accept DateTime objects. It can also read.evtx files with -Path and collapsed providers with -ProviderName, covering most of what wevtutil does with friendlier output.

03Risk

RiskLow risk

04Undo

✓No undo needed — this command does not change persistent state.

05Sources

  • Get-WinEvent
    Microsoft Learn · vendor-doc · 2026-09-17
    Evidence: Documents FilterHashtable parameters including LogName, Level, and StartTime for server-side filtering.
  • Get-WinEvent - SS64
    SS64 · technical · 2026-09-17
    Evidence: Shows FilterHashtable usage examples for querying System and Application logs by level and date range.

Last verified: 2026-09-17 · Category: System & Settings

06Related solutions