Перейти к основному содержимому
Windows Event Logs: Security, System & PowerShell
Урок 9 из 10

Windows Event Logs: Security, System & PowerShell

Learn how Windows records authentication, service, and script activity in EVTX logs, and how to filter and interpret key event IDs with Event Viewer and Get-WinEvent.

Средний 24 мин Linux и Windows
Этого урока пока нет на выбранном языке — показана версия на другом языке. Перевод готовится.
Только в разрешённой среде — Описанные здесь приёмы применяются только в учебных лабораториях и в системах, которые принадлежат вам или на которые есть письменное разрешение.

Цели обучения

  • Distinguish the roles of the Security, System, Application, and PowerShell Operational logs
  • Interpret high-value Event IDs including 4624, 4625, 4672, 4688, 7045, 1102, and 4104
  • Query live and offline EVTX files efficiently using Get-WinEvent with FilterHashtable
  • Identify log gaps, retention weaknesses, and audit policy omissions that hinder investigations

Рекомендуется заранее: Windows Architecture, Processes & Registry BasicsPowerShell Cmdlets, Objects & PipelineWindows Users, Groups, ACLs & Services

#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.
Attack activity across three log channelsAttack activity across three log channelsAttackerHostSecurityPowerShell Operat...SystemFailed RDP password (192.0.2.50)Event 4625 (LogonType 10)Valid admin RDP logonEvent 4624 (LogonType 10) + Event 4672Runs obfuscated PowerShell commandEvent 4104 (decoded ScriptBlockText)Registers persistence serviceEvent 7045 (ServiceName, ImagePath)

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:

powershell
# 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 10

Replace LogName with Path to inspect an exported .evtx file:

Triaging an exported Security capture in a lab
$ 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   3

Because .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

  1. Enable AuditingTurn on 4688 CLI & 4104 Script Block
  2. Size LogsRaise Security.evtx above 20 MB default
  3. Forward Off-HostStream via WEF or SIEM agent
  4. Alert on GapsTrigger alert on Event ID 1102 or 104
  • Filtering with Where-Object too early: Get-WinEvent -LogName Security | Where-Object { $_.Id -eq 4625 } loads every event before filtering. Always use -FilterHashtable or -FilterXPath.
  • Keeping default log sizes: A 20 MB Security.evtx wraps 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) and 104 (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.

Проверка знаний

Войдите, чтобы проходить тест, завершать уроки и сохранять прогресс. Войти в систему

Практика: проверьте свои знания