#Why this matters
Every logon attempt, new service, and encoded PowerShell command leaves traces in Windows Event Logs unless logging is disabled or overwritten. When investigating suspicious host activity, .evtx files are often the most reliable source of ground truth. Knowing which channels hold which evidence, and filtering them with PowerShell, lets you triage thousands of records in seconds on live systems or exported captures.
#Core log channels and EVTX storage
Windows stores event logs as binary XML .evtx files in C:\Windows\System32\winevt\Logs\. Four channels form the baseline for host triage:
| Log / Channel | Default File | Primary Evidence | Read Access |
|---|---|---|---|
| Security | Security.evtx |
Logons, privileges, process creation, log clearing | Admin / Event Log Readers |
| System | System.evtx |
Service installs, drivers, startups, shutdowns | Standard users |
| Application | Application.evtx |
App crashes, MSI installs, custom app errors | Standard users |
| PowerShell Operational | Microsoft-Windows-PowerShell%4Operational.evtx |
Script Block (4104) and Module Logging (4103) | Admin for all users |
Event Viewer (eventvwr.msc) lets you browse channels interactively and inspect captures via Open Saved Log. For repeatable searches across large logs, PowerShell is much faster.
#High-value Event IDs for defenders
A small group of Event IDs answers most initial triage questions: who authenticated, how they arrived, what persisted, and whether PowerShell ran.
| Event ID | Log | Meaning | Key Fields |
|---|---|---|---|
4624 |
Security | Successful logon | TargetUserName, LogonType, IpAddress |
4625 |
Security | Failed logon | TargetUserName, LogonType, IpAddress, SubStatus |
4672 |
Security | Special privileges assigned | SubjectUserName, PrivilegeList |
4688 |
Security | New process created (needs audit policy) | NewProcessName, CommandLine |
7045 |
System | New service installed | ServiceName, ImagePath, StartType |
1102 |
Security | Security audit log cleared | SubjectUserName, SubjectDomainName |
4104 |
PowerShell Operational | Script block executed | ScriptBlockText, Path, UserId |
For 4624 and 4625, Logon Type shows how the session started:
- Type 2 (Interactive): Local keyboard and console logon.
- Type 3 (Network): Network access such as SMB shares or WinRM.
- Type 7 (Unlock): Unlocking a locked workstation.
- Type 10 (RemoteInteractive): Remote Desktop Protocol (RDP) session.
Correlating these IDs builds a clear timeline: repeated 4625 failures from 192.0.2.50, a 4624 (LogonType 10) with 4672, a 4104 script block, and a 7045 service creation.
#Querying logs with Get-WinEvent
Use Get-WinEvent instead of the legacy Get-EventLog cmdlet, which cannot read operational channels like Microsoft-Windows-PowerShell/Operational or offline .evtx files.
Pass -FilterHashtable so the Windows Event Log engine filters records before creating PowerShell objects:
# Failed logons in the last 24 hours
$Yesterday = (Get-Date).AddDays(-1)
Get-WinEvent -FilterHashtable @{
LogName = 'Security'
Id = 4625
StartTime = $Yesterday
} | Select-Object TimeCreated, Id, Message -First 10Replace LogName with Path to inspect an exported .evtx file:
$ pwsh -Command "Get-WinEvent -FilterHashtable @{ Path='.\lab-security.evtx'; Id=4624 } | Select-Object -First 2 TimeCreated, Id, @{N='User';E={$_.Properties[5].Value}}, @{N='Type';E={$_.Properties[8].Value}}"
TimeCreated Id User Type
----------- -- ---- ----
11/18/2026 2:14:09 PM 4624 jsmith 10
11/18/2026 2:14:09 PM 4624 jsmith 3Because .Message formatting varies by locale, reliable scripts read structured fields from [xml]$Event.ToXml() or $Event.Properties rather than regex on text.
#Defending and common mistakes
- Enable AuditingTurn on 4688 CLI & 4104 Script Block
- Size LogsRaise Security.evtx above 20 MB default
- Forward Off-HostStream via WEF or SIEM agent
- Alert on GapsTrigger alert on Event ID 1102 or 104
- Filtering with
Where-Objecttoo early:Get-WinEvent -LogName Security | Where-Object { $_.Id -eq 4625 }loads every event before filtering. Always use-FilterHashtableor-FilterXPath. - Keeping default log sizes: A 20 MB
Security.evtxwraps quickly on busy hosts, overwriting evidence. Raise maximum sizes and forward logs to a SIEM. - Missing CLI and script auditing: Enable process creation (
4688) with command-line logging and PowerShell Script Block Logging (4104) so encoded commands are captured in readable form. - Ignoring log clearing: Event
1102(Security cleared) and104(System or Application cleared) signal tampering and must trigger immediate alerts.
#Summary
Windows Event Logs separate authentication, system, and script evidence across .evtx channels in C:\Windows\System32\winevt\Logs\. Knowing key Event IDs (4624, 4625, 4672, 4688, 7045, 1102, 4104) and querying with Get-WinEvent -FilterHashtable enables rapid timeline reconstruction. Complete visibility requires enabling command-line and script logging, increasing log sizes, and forwarding events off-host.