Investigating EmailEvents in Microsoft Defender XDR
The first query returned thousands of results.
Too much noise.
So the defender filtered the time range, removed unnecessary columns, grouped activity, found unusual spikes and ranked the busiest devices.
Slowly, the investigation became clear.
In this final Agent Foskett Academy foundation lesson, you will learn how defenders combine where, project, summarize, count(), bin(), distinct, top and order by into real Microsoft Defender XDR and Sentinel investigations.
Lesson overview
Learn how to combine KQL operators into a practical investigation workflow across Microsoft Defender XDR and Microsoft Sentinel telemetry.
Why combining operators matters
Real investigations do not work that way.
Defenders usually filter the dataset, choose the useful columns, count activity, group it over time, rank the busiest values and sort the evidence into a timeline.
Investigation scenario
The first query returns thousands of events.
The goal is to reduce the noise and identify which devices, users and time windows are worth deeper investigation.
Step 1 — Filter the telemetry
- 1
- 2
- 3
- 4
- 5
DeviceProcessEvents | where Timestamp > ago(24h) | where FileName == "powershell.exe"
Show PowerShell process events from the last 24 hours.
Step 2 — Remove unnecessary columns
- 1
- 2
- 3
- 4
- 5
- 6
DeviceProcessEvents | where Timestamp > ago(24h) | where FileName == "powershell.exe" | project Timestamp, DeviceName, AccountName, ProcessCommandLine
Step 3 — Count activity by device
- 1
- 2
- 3
- 4
- 5
- 6
DeviceProcessEvents | where Timestamp > ago(24h) | where FileName == "powershell.exe" | summarize ProcessCount=count() by DeviceName
Step 4 — Rank the busiest devices
- 1
- 2
- 3
- 4
- 5
- 6
- 7
DeviceProcessEvents | where Timestamp > ago(24h) | where FileName == "powershell.exe" | summarize ProcessCount=count() by DeviceName | top 10 by ProcessCount
Step 5 — Identify time spikes
- 1
- 2
- 3
- 4
- 5
- 6
- 7
DeviceProcessEvents | where Timestamp > ago(24h) | where FileName == "powershell.exe" | summarize ProcessCount=count() by bin(Timestamp, 15m) | order by Timestamp asc
Count PowerShell events in 15-minute windows so suspicious bursts become easier to see.
Step 6 — Find unique devices involved
- 1
- 2
- 3
- 4
- 5
- 6
DeviceProcessEvents | where Timestamp > ago(24h) | where FileName == "powershell.exe" | distinct DeviceName
Putting it together
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
DeviceProcessEvents | where Timestamp > ago(24h) | where FileName == "powershell.exe" | project Timestamp, DeviceName, AccountName, ProcessCommandLine | summarize ProcessCount=count() by DeviceName | top 10 by ProcessCount
Investigator mindset
Real defenders build investigations step by step.
Each operator removes noise, adds context or reveals the next useful pivot.
The logs already knew.
The defender simply learned how to ask better questions.
What you learned
Continue your investigation
Continue learning with KQL Threat Hunting, EmailEvents KQL Guide, DMARC Failures KQL, Microsoft Security and the GEMXIT Security Review.
Develop IT. Protect IT. GEMXIT PTY LTD | GEMXIT UK LTD