Query Details
// All credit goes to Felix Brand - Taken from his post (https://www.linkedin.com/posts/felix-brand_defenderxdr-kql-microsoft-activity-7228749401849040896-0sNk)
// Microsoft now recommends (https://lnkd.in/ewBryvhF) to have one initial full scan when you onboard your system into MDE. But MDE does not trigger a full scan after onboarding, this KQL query combined with a custom detection rule can trigger a scan.
// Once a scan is completed on an endpoint, it will not appear in this query again.
let AvModeDescription = dynamic({"0":"Normal", "1":"Passive", "4":"EDR Block"});
let TimeRange = ago(1d);
DeviceTvmInfoGathering
| where Timestamp > TimeRange
| extend AdditionalFields = parse_json(AdditionalFields)
| extend AvMode = tostring(AvModeDescription[tostring(AdditionalFields.["AvMode"])])
| extend FullScanStatus = coalesce(extractjson("$.Full.ScanStatus", tostring(AdditionalFields.AvScanResults)),"Not available")
| where isnotempty( AvMode ) and AvMode has "Normal"
| where FullScanStatus !has "Completed"
| join DeviceEvents on DeviceName
| summarize arg_max(Timestamp, *) by DeviceName, DeviceId
| project DeviceName, DeviceId, FullScanStatus, ReportId, Timestamp
| take 50
This KQL (Kusto Query Language) query is designed to identify devices that have not yet completed a full antivirus scan after being onboarded into Microsoft Defender for Endpoint (MDE). Here's a simplified breakdown of what the query does:
Define Variables:
AvModeDescription: A mapping of antivirus modes to their descriptions (e.g., "Normal", "Passive", "EDR Block").TimeRange: Sets the time range to the last 24 hours (ago(1d)).Filter Data:
DeviceTvmInfoGathering table for records from the last 24 hours.AvMode) and the full scan status (FullScanStatus).Filter Conditions:
Join and Summarize:
DeviceEvents table on DeviceName.arg_max(Timestamp, *)).Select and Limit Results:
In essence, this query helps identify up to 50 devices that are in "Normal" antivirus mode but have not yet completed a full scan, allowing administrators to take action to ensure these scans are performed.

Nathan Hutchinson
Released: February 2, 2026
Tables
Keywords
Operators