Get-WinEvent

Get-WinEvent is the primary PowerShell cmdlet for querying Windows event logs. It replaces the legacy Get-EventLog cmdlet and supports both live logs and archived .evtx files.

Basic usage

# Get help
Get-Help Get-WinEvent
 
# List all logs available on the system
Get-WinEvent -ListLog *
 
# List providers (sources) for a specific log
Get-WinEvent -ListProvider * -LogName Application

Filtering

Two approaches — -FilterHashtable is strongly preferred:

Where-Object (post-filtering — slow for large logs)

Pipes all events through Where-Object after retrieval. Works on any source including archived logs (-Path).

Get-WinEvent -LogName Application | Where-Object {
    $_.ProviderName -Match 'WLMS'
}
 
# Match by event ID (note the different syntax)
Get-WinEvent -LogName Application | Where-Object Id -eq 100

-FilterHashtable (filter at the source — fast)

Filtering is done during the query itself. More efficient and cleaner syntax, but only works against live logs — use Where-Object for archived logs via -Path.

Get-WinEvent -FilterHashtable @{
    LogName      = 'Application'
    ProviderName = 'WLMS'
}
 
# Filter by event ID and time range
Get-WinEvent -FilterHashtable @{
    LogName   = 'Security'
    Id        = 4625
    StartTime = (Get-Date).AddDays(-1)
    EndTime   = Get-Date
}

FilterHashtable keys

KeyTypeNotes
LogNameStringWildcards supported
ProviderNameStringWildcards supported
PathStringPath to .evtx file
KeywordsLongSee keyword values below
IDInt32Event ID
LevelInt32See level values below
StartTimeDateTime
EndTimeDateTime
UserIDSID
DataStringEvent data string

Hash keys can be written with newlines instead of semicolons for readability.

Keyword values

KeywordValue
AuditFailure4503599627370496
AuditSuccess9007199254740992
CorrelationHint218014398509481984
EventLogClassic36028797018963968
Sqm2251799813685248
WdiDiagnostic1125899906842624
WdiContext562949953421312
ResponseTime281474976710656
None0

Level values

LevelValue
Verbose5
Informational4
Warning3
Error2
Critical1
LogAlways0

Displaying full event details

# Show all properties of an event
Get-WinEvent -LogName Application -MaxEvents 1 | Format-List -Property *

Security use cases

  • Hunt for AMSI bypass attempts via PowerShell script block logging (event 4104 in Microsoft-Windows-PowerShell/Operational)
  • Detect log clearing (events 104/1102) — see windows-event-logs > notable-event-ids
  • Correlate 4624/4625 logon events to identify brute-force or lateral movement
  • Review 4688 process creation events for suspicious command lines

Sources

Related: windows-event-logs, amsi-bypass, windows-reconnaissance-commands