Query Details

Latest Antivirus Scan Status

Query

DeviceEvents
| where ActionType == "AntivirusScanCompleted"
| summarize arg_max(Timestamp, *) by DeviceId
| extend ScanType = tostring(parse_json(AdditionalFields).ScanTypeIndex), 
    DaysAgo = datetime_diff('day', now(), Timestamp)
| project DeviceName, ActionType, ScanType, DaysAgo
// Filter only devices that have not performed a antivirus scan in the last day
| where DaysAgo > 0
| sort by DaysAgo

About this query

Latest Antivirus Scan Status

Query Information

Description

This query lists the latest completed antivirus scan for each device. The query filters all devices that have performed a successful scan today.

Risk

The Defender sensor is not working corretly and might not be able to idenfity suspicious behaviour.

References

Defender XDR

Sentinel

DeviceEvents
| where ActionType == "AntivirusScanCompleted"
| summarize arg_max(TimeGenerated, *) by DeviceId
| extend ScanType = tostring(parse_json(AdditionalFields).ScanTypeIndex), 
    DaysAgo = datetime_diff('day', now(), Timestamp)
| project DeviceName, ActionType, ScanType, DaysAgo
// Filter only devices that have not performed a antivirus scan in the last day
| where DaysAgo > 0
| sort by DaysAgo

Explanation

This query is designed to identify devices that have not completed an antivirus scan today. It works by looking at the latest antivirus scan event for each device and checking when it occurred. Here's a simple breakdown of what the query does:

  1. Data Source: It looks at events related to antivirus scans from a dataset called DeviceEvents.

  2. Filter for Completed Scans: It specifically filters for events where an antivirus scan has been completed, indicated by the ActionType being "AntivirusScanCompleted".

  3. Find Latest Scan per Device: For each device, it finds the most recent scan event using the summarize arg_max function, which selects the event with the latest timestamp.

  4. Extract Additional Information: It extracts the type of scan performed and calculates how many days ago the scan happened.

  5. Project Relevant Information: It selects only the necessary information to display: the device name, action type, scan type, and days since the last scan.

  6. Filter for Devices Needing Attention: It filters out devices that have performed a scan today, focusing only on those that haven't scanned in the last day.

  7. Sort Results: Finally, it sorts the devices by how many days ago their last scan was completed, showing those with the oldest scans first.

This query helps identify devices that might be at risk because they haven't been scanned recently, which could indicate that the Defender sensor isn't working correctly.

Details

Bert-Jan Pals profile picture

Bert-Jan Pals

Released: October 20, 2024

Tables

DeviceEvents

Keywords

DeviceEventsIdNameActionTypeScanDaysAgoAdditionalFieldsTimestampTimeGenerated

Operators

wheresummarizearg_maxextendtostringparse_jsondatetime_diffnowprojectsort

Actions

GitHub