defender_run_hunting_query
Run KQL advanced hunting queries across Defender XDR data to investigate threats across endpoint, identity, email, and cloud apps.
Instructions
Run an advanced hunting query (KQL) across Defender XDR data: endpoint, identity, email and cloud apps in one query. Tables include AlertInfo, AlertEvidence, DeviceProcessEvents, DeviceNetworkEvents, DeviceFileEvents, DeviceRegistryEvents, DeviceLogonEvents, DeviceEvents, IdentityLogonEvents, IdentityDirectoryEvents, EmailEvents, EmailUrlInfo, UrlClickEvents and CloudAppEvents. Which tables hold data depends on the tenant's licences: an empty result from a table that defender_get_capabilities reports as empty or not exposed is a visibility gap, not a finding and not a permissions problem. The sensor records no creation event for some processes (services started before it, some short-lived instances): a process absent from DeviceProcessEvents may still be there as the InitiatingProcessId and InitiatingProcessCreationTime of other events, so look there before concluding it did not run. Match a process by PID together with its creation time, never by PID alone. Timestamps are UTC. Data is limited to the last 30 days. Example: "DeviceProcessEvents | where Timestamp > ago(1d) | where FileName =~ 'powershell.exe' | project Timestamp, DeviceName, ProcessCommandLine | limit 50".
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | The Kusto Query Language (KQL) query. End exploratory queries with '| limit N' to keep results context-friendly. | |
| timespan | No | ISO 8601 duration limiting how far back to query, e.g. 'P7D' or 'PT12H'. Defaults to the service maximum (30 days). |