Windows event logs: event IDs, Get-WinEvent and XPath
-
Phase 0: Before you start
-
Phase 1: The foundation
-
Phase 2: Core administration and security
-
Phase 3: Enterprise infrastructure
-
Phase 4: Troubleshooting step by step
-
Phase 5: Final project and career
Back in Lesson 42 you asked “what changed?” and the event logs gave you the answer. This time you’ll learn Windows event logs properly: where they live, which event IDs matter and how to search through millions of events in a few seconds.
You’ll filter logs quickly with Get-WinEvent, use XPath to pull usernames and IP addresses out of failed logons, put together a daily summary, and try the DTrace that now comes built into Server 2025.
| Time | You need | By the end you can |
|---|---|---|
| About 75 minutes | DC01, SRV01 and CL01 | Find any event quickly, read the fields inside it, and use an event ID cheat sheet at work |
What it is, in one line
Think of Windows event logs as the server’s diary, where every service, driver and security check writes dated entries that you can search later.
In Simple Words
In Simple Words
Picture a school with a big register at the gate. Whenever someone comes in, goes out or forgets their ID card, the guard writes a line with the time, the name and what happened. Most days nobody looks at it, but when a bicycle goes missing, that register tells you who walked in at 3 PM. Event logs work the same way: you don’t read them for fun, you search them when something breaks, so you need to know which page to open and what each line code means.
Engineer's View
Engineer’s View
Channels: the Windows logs are Application, Security, Setup, System and Forwarded Events. Under Applications and Services Logs every component gets its own channels (Admin, Operational, plus the hidden Analytic and Debug ones), for example Microsoft-Windows-DNSServer/Audit or Microsoft-Windows-GroupPolicy/Operational.
Files: logs sit as .evtx files in C:\Windows\System32\winevt\Logs. Each one has a maximum size and a retention mode, which can be overwrite as needed, archive when full, or don’t overwrite.
Event fields: each event carries a provider (source), event ID, level (1 Critical, 2 Error, 3 Warning, 4 Information), task, keywords (Audit Success, Audit Failure), TimeCreated (stored in UTC but shown in local time), computer, user, and EventData with named fields such as TargetUserName or IpAddress.
Querying: when you use Get-WinEvent with -FilterHashtable or -FilterXPath, the filtering happens inside the event log service, which is far quicker than pulling everything back and piping it to Where-Object. From cmd, wevtutil does the same job and can also change log settings.
Security log: only the events your audit policy has turned on get written here, and to read it you need administrator rights or membership in Event Log Readers.
DTrace: Server 2025 ships with dtrace built in. Turn it on with bcdedit /set dtrace on, restart, and you can trace live system calls when the logs don’t tell you enough.
How it works, step by step
How an event gets from a component to you:
A provider (a service, driver or Windows component) writes events into a channel, the event log service saves them in an .evtx file, and you read them with Event Viewer, Get-WinEvent or a collector that receives forwarded events.
These are the event IDs worth remembering:
| Log | Event ID | Meaning |
|---|---|---|
| System | 41 / 6008 | Unexpected shutdown (crash, hang or power loss) |
| System | 1074 | Planned restart or shutdown, with user and reason |
| System | 6005 / 6006 | Event log service started / stopped (boot and shutdown) |
| System | 7031 / 7034 | Service stopped unexpectedly |
| System | 7036 / 7040 / 7045 | Service state change / start type change / new service |
| System | 104 | Log cleared |
| System | 5719 | Netlogon couldn’t reach a domain controller |
| System | 1014 | DNS client name resolution timed out |
| Security | 4624 / 4625 | Logon succeeded / failed |
| Security | 4740 / 4767 | Account locked out / unlocked |
| Security | 4720 / 4726 | User account created / deleted |
| Security | 4728 / 4732 | Member added to a global / local security group |
| Security | 4768 / 4769 / 4771 | Kerberos TGT / service ticket / pre-auth failed |
| Security | 4776 | NTLM credential validation |
| Security | 1102 | Security log cleared |
| Application | 1000 | Application crash (faulting module) |
| Setup | 2 | Update package installed |
Which tool to use for which job:
In the lab you’ll:
- List the logs on SRV01 and see their sizes.
- Compare a slow and a fast way to filter events.
- Create failed logons and read the user, IP and failure code with XPath.
- Build a daily summary of important event IDs.
- Try DTrace on Server 2025 (optional).
Hands-on lab: find any event fast
Before you run any command, double-check it
Read every command twice before you press Enter. Check the target: the system or account, the IDs, the names and the sizes. These commands are for learning and were tested in our lab, not on your system. At work, run the read-only list commands first, follow your change process, make sure a backup exists, and ask a second person to check anything that changes or deletes data. You run them at your own risk.
Start DC01, SRV01 and CL01. Unless a step says otherwise, work as SAATLAB\adm.rahul in PowerShell as administrator.
1List the logs and their sizes
On SRV01:
Get-WinEvent -ListLog * -ErrorAction SilentlyContinue |
Where-Object RecordCount -gt 0 |
Sort-Object RecordCount -Descending |
Select-Object -First 6 LogName, RecordCount,
@{ n = 'MaxMB'; e = { [math]::Round($_.MaximumSizeInBytes / 1MB) } }, LogModeYou’ll see something like this:
LogName RecordCount MaxMB LogMode
------- ----------- ----- -------
Security 31842 128 Circular
System 6120 20 Circular
Application 2875 20 Circular
Microsoft-Windows-PowerShell/Operational 2210 15 Circular
Windows PowerShell 1460 15 Circular
Microsoft-Windows-TaskScheduler/Operational 1102 10 CircularCircular means “overwrite as needed”: once the log fills up, the oldest events are thrown away, so its size and how busy it is decide how much history you keep or lose.
✅ Checkpoint: You can see each log’s record count, size limit and retention mode.
2Filter the slow way and the fast way
On SRV01, look for errors in the System log from the last 7 days, once each way:
$since = (Get-Date).AddDays(-7)
(Measure-Command {
Get-WinEvent -LogName System | Where-Object { $_.Level -eq 2 -and $_.TimeCreated -ge $since }
}).TotalSeconds
(Measure-Command {
Get-WinEvent -FilterHashtable @{ LogName = 'System'; Level = 2; StartTime = $since } -ErrorAction SilentlyContinue
}).TotalSecondsYou’ll see something like this:
3.9417318
0.1288421Where-Object pulls every event into PowerShell and then throws most of them away, while FilterHashtable asks the event log service to do the filtering so only the matching events come back. On a busy DC with millions of Security events, that can be the difference between a few seconds and many minutes.
✅ Checkpoint: FilterHashtable is many times faster than Where-Object for the same result.
3Read failed logons with XPath
On CL01, open a normal PowerShell window and type a wrong password three times on purpose:
1..3 | ForEach-Object { net use \\DC01\IPC$ /user:SAATLAB\kiran.das WrongPass1 }You’ll see something like this (three times):
System error 1326 has occurred.
The user name or password is incorrect.Now go to DC01, find those failures and pull out the fields you care about:
$xpath = "*[System[EventID=4625] and EventData[Data[@Name='TargetUserName']='kiran.das']]"
Get-WinEvent -LogName Security -FilterXPath $xpath -MaxEvents 3 | ForEach-Object {
$d = @{}
([xml]$_.ToXml()).Event.EventData.Data | ForEach-Object { $d[$_.Name] = $_.'#text' }
[pscustomobject]@{
Time = $_.TimeCreated
User = $d.TargetUserName
IP = $d.IpAddress
LogonType = $d.LogonType
SubStatus = $d.SubStatus
}
} | Format-TableYou’ll see something like this:
Time User IP LogonType SubStatus
---- ---- -- --------- ---------
19/10/2026 14:02:31 kiran.das 10.0.0.150 3 0xc000006a
19/10/2026 14:02:31 kiran.das 10.0.0.150 3 0xc000006a
19/10/2026 14:02:30 kiran.das 10.0.0.150 3 0xc000006aLogon type 3 means a network logon, the IP tells you it came from CL01, and sub status 0xC000006A means the password was wrong. A few other codes you’ll run into: 0xC0000064 (the user doesn’t exist), 0xC0000234 (locked out) and 0xC0000072 (account disabled).
✅ Checkpoint: You found three 4625 events with user, source IP and sub status.

4Build a daily event summary
On SRV01, count how many of the cheat-sheet events showed up in the last 24 hours:
$ids = 41, 104, 1074, 6008, 7031, 7034, 7040, 7045
$start = (Get-Date).AddDays(-1)
Get-WinEvent -FilterHashtable @{ LogName = 'System'; Id = $ids; StartTime = $start } -ErrorAction SilentlyContinue |
Group-Object Id |
Sort-Object Count -Descending |
Select-Object @{ n = 'EventId'; e = { $_.Name } }, Count,
@{ n = 'Last'; e = { ($_.Group | Sort-Object TimeCreated)[-1].TimeCreated } }You’ll see something like this:
EventId Count Last
------- ----- ----
7040 4 19/10/2026 13:10:51
1074 1 19/10/2026 12:31:08
6008 1 19/10/2026 13:22:09
41 1 19/10/2026 13:21:58
104 1 19/10/2026 13:10:44If you run this every morning (or schedule it as you did in Lesson 27), you’ll catch crashes, restarts and service changes before users start calling.
✅ Checkpoint: The summary shows counts and the last time for each important System event.
5Optional: trace live with DTrace
On SRV01 (Server 2025), enable DTrace and restart:
bcdedit /set dtrace on
Restart-ComputerOnce it’s back up, count system calls per process for a few seconds and then press Ctrl+C:
dtrace -n "syscall:::entry { @[execname] = count(); }"You’ll see something like this:
svchost.exe 1844
lsass.exe 2210
MsMpEng.exe 5932
System 9120[Add your screenshot here]
DTrace shows you what’s happening right now, underneath the level of events, so reach for it when a process is busy but the logs say nothing. When you’re finished, switch it off with bcdedit /set dtrace off and restart.
✅ Checkpoint: dtrace lists processes with their system call counts.
Break It, Then Fix It
In real scripts you’ll run into two problems: errors that aren’t really errors, and people who can’t read the logs when they should (or can when they shouldn’t).
1Break it: a typo and an empty result
On SRV01, run two queries, one with a typo in the log name and one for an event that has never happened:
Get-WinEvent -FilterHashtable @{ LogName = 'Sytem'; Id = 41 }
Get-WinEvent -FilterHashtable @{ LogName = 'System'; Id = 9999 }You’ll see something like this:
Get-WinEvent : There is not an event log on the localhost computer that matches "Sytem".
Get-WinEvent : No events were found that match the specified selection criteria.The first one is a genuine mistake. The second is good news, yet Get-WinEvent reports it as an error, and that can stop a script or fill your error report with noise.
To fix it, check the log name and handle “no events” deliberately:
Get-WinEvent -ListLog Sys* | Select-Object LogName
$e = Get-WinEvent -FilterHashtable @{ LogName = 'System'; Id = 9999 } -ErrorAction SilentlyContinue
if (-not $e) { 'No events with ID 9999: OK' }You should see something like this:
LogName
-------
System
No events with ID 9999: OK✅ Checkpoint: The typo gave a “no event log” error, and the empty query is now handled cleanly.
2Break it: a helpdesk user can’t read the Security log
On SRV01, sign in at the console as SAATLAB\sneha.reddy (she’s not an admin) and run:
Get-WinEvent -LogName Security -MaxEvents 1You’ll see something like this:
Get-WinEvent : Attempted to perform an unauthorized operation.The Security log is protected, and you don’t want to turn helpdesk staff into local administrators just so they can read it.
To fix it, sign in as adm.rahul and add GG_IT to the built-in Event Log Readers group on SRV01:
Add-LocalGroupMember -Group 'Event Log Readers' -Member 'SAATLAB\GG_IT'
Get-LocalGroupMember -Group 'Event Log Readers'You’ll see something like this:
ObjectClass Name PrincipalSource
----------- ---- ---------------
Group SAATLAB\GG_IT ActiveDirectory
Sneha signs out and back in to pick up a new token (as in Lesson 16), runs the same command, and this time gets the latest Security event back.
✅ Checkpoint: sneha.reddy was denied, then could read the Security log after joining Event Log Readers through GG_IT.
This happened at work
The breach investigation with only six hours of history
It started when the security team noticed a service account logging on to servers it had never used. They came to the Windows team and asked for every logon by that account over the last month, and that’s when the team found the Security log on the busiest DC was still at its default size. With thousands of logons a minute it only held about six hours of events, the other DCs were no better, and nothing was being forwarded anywhere. So the investigators could watch what the attacker was doing now but couldn’t see how they got in, and rebuilding the timeline from firewall and VPN logs cost them two extra weeks.
The fix: the team raised the Security logs on the DCs to several gigabytes, started forwarding key events to a central collector, and added a weekly check that reports how many days each log really holds.
The lesson: size logs by time, not by megabytes, and ask yourself “how many days does this log keep?” well before you need the answer.
Common mistakes and troubleshooting
| Mistake | What happens | What to do instead |
|---|---|---|
| Piping everything to Where-Object | Queries take minutes on busy servers | Use -FilterHashtable or -FilterXPath |
| Treating “No events were found” as a failure | Scripts stop or report false errors | Use -ErrorAction SilentlyContinue and check for empty results |
| Reading only the Message text | Fields are hard to parse | Read EventData from the event XML |
| Forgetting that times are UTC inside | Time filters in XPath miss events | Use StartTime in FilterHashtable or timediff() in XPath |
| Default log sizes on busy servers | History lost within hours | Size by days of history; forward events |
| Making helpdesk staff admins to read logs | Too much access | Use the Event Log Readers group |
| No audit policy | The Security events you need never appear | Set advanced audit policy by GPO (Lesson 23) |
| Leaving DTrace on | Extra overhead and a larger attack surface | Turn it off after troubleshooting |
Interview questions
Click a question to open it. Each one is worded the way an interviewer would ask it, and underneath you’ll see why they ask and one way you could answer in your own words.
Fresher level
1. When you open Event Viewer, which main logs would you expect to see?
Why they ask this: They’re checking you know where Windows keeps its logs before they get into specific events.
How you might answer: Under Windows Logs you’ve got Application, Security, Setup, System and Forwarded Events, and under Applications and Services Logs each component, like DNS Server or a role, has its own logs. Most of my day-to-day troubleshooting starts in System and Application.
2. You see a lot of events 4624 and 4625 in the Security log. What do they mean?
Why they ask this: They want to see that you recognise the most common security event IDs.
How you might answer: 4624 is a successful logon and 4625 is a failed one, and both sit in the Security log. If I saw a sudden burst of 4625 events I’d look into it, because that can mean a wrong saved password or someone guessing passwords.
3. A server restarted in the night. How would you find out who or what restarted it?
Why they ask this: They want to see you use the logs to answer a simple, real question.
How you might answer: I’d filter the System log for event 1074, which shows the user, the process that kicked off the restart and the reason that was given. In PowerShell that’s quick with Get-WinEvent and a filter on ID 1074.
2–5 years experience
4. Why would you use -FilterHashtable with Get-WinEvent instead of piping to Where-Object?
Why they ask this: They’re checking that you write efficient queries, especially against large logs.
How you might answer: With -FilterHashtable the event log service does the filtering and only the matching events come back to PowerShell. With Where-Object every event gets read first and filtered afterwards, and on a big Security log that’s seconds against minutes.
5. You find a failed logon event. How would you pull out the source IP address and the reason it failed?
Why they ask this: They want to know you can read the detailed data inside an event and not only the message text.
How you might answer: I’d convert the event to XML and read the EventData fields such as IpAddress, TargetUserName, LogonType and SubStatus, where the SubStatus code tells me why the logon failed. If I had to search lots of events by those fields, I’d filter with XPath instead.
6. A helpdesk colleague needs to read event logs on servers, but shouldn’t be an admin. How would you give them access?
Why they ask this: They’re looking for least privilege instead of someone who hands out admin rights.
How you might answer: I’d put them in the Event Log Readers group. On one server I can do that locally, but for many servers I’d use a GPO with Restricted Groups or Group Policy Preferences, so they can read the logs and still can’t change anything else.
Senior level
7. How would you decide how long to keep event logs across 200 servers?
Why they ask this: They want to see you plan at scale and think about security as well as disk space.
How you might answer: First I’d work out how many days of history each log needs for the server’s role and size the logs to match. Key events would go to a SIEM through WEF or an agent, so there’s a central copy, and I’d alert on events 1102 and 104 because they mean someone cleared a log.
8. A user’s account keeps locking out every hour. How would you track down where it’s coming from?
Why they ask this: They want to see you can follow a trail through the logs across several machines.
How you might answer: I’d start with event 4740 on the PDC emulator, which gives the caller computer name, and then look at the 4625 or 4771 events on that machine. Usually it turns out to be stale credentials somewhere, like a service, a scheduled task, a mapped drive or a phone that still has the old password.
9. A process is misbehaving, but the event logs show nothing useful. What would you try next?
Why they ask this: They want to know you have deeper tools for when the logs run dry.
How you might answer: On Server 2025 I’d turn to DTrace, which traces live system calls and file or registry activity with low overhead. That shows me what the process is doing, which the event logs can’t.
Quick quiz
Q1. Where are .evtx files stored?
- C:\Windows\Logs
- C:\Windows\System32\winevt\Logs
- C:\ProgramData\Events
Show answer
B — One file per log.
Q2. Which is faster on a big log?
- Where-Object
- -FilterHashtable
- Sort-Object
Show answer
B — Filtering happens in the event log service.
Q3. What does sub status 0xC000006A mean in a 4625?
- Account disabled
- Wrong password
- User does not exist
Show answer
B — 0xC0000064 is an unknown user.
Q4. Which group lets a non-admin read the Security log?
- Remote Desktop Users
- Event Log Readers
- Backup Operators
Show answer
B — Least privilege.
Q5. In the work story, why was history missing?
- Logs were cleared
- The Security log was too small for a busy DC
- Auditing was off
Show answer
B — Size logs by days.
Quick recap
- Windows event logs live in .evtx files, one per channel, and each has a size limit and a retention mode.
- Know the key IDs: 41, 1074, 6008, 7036, 7040, 7045, 4624, 4625, 4740, 4771, 1102.
- Filter with
-FilterHashtableor-FilterXPath, not Where-Object. - Read EventData from the XML when you need users, IPs and status codes.
- Use Event Log Readers instead of admin rights.
- Server 2025 has DTrace built in for live tracing.
Next lesson
Lesson 44: Network diagnostics → Next you’ll troubleshoot connections one layer at a time with Test-NetConnection, Resolve-DnsName and pathping, and capture packets with the built-in pktmon tool.
Further reading: Windows event logs
Want to go deeper into Windows event logs? Microsoft’s Get-WinEvent reference covers every filter option, the 4625 event reference explains each field of a failed logon, and the dtrace command page shows how to enable DTrace. You can also see the full plan for this course on the Windows Server Administration course page.
