Review suspicious PowerShell process launches
Find PowerShell process executions with common download, encoded-command, hidden-window, or bypass indicators.
intermediateendpointransomware
- Run surface
- Defender XDR Advanced Hunting, Sentinel Logs
- Required tables
- DeviceProcessEvents
- License context
- Microsoft Defender for Endpoint P2
kql
let lookback = {lookback};
let suspiciousTerms = dynamic(["-enc", "encodedcommand", "downloadstring", "invoke-webrequest", "iex", "-w hidden", "bypass"]);
DeviceProcessEvents
| where Timestamp > ago(lookback)
| where FileName in~ ("powershell.exe", "pwsh.exe")
| where ProcessCommandLine has_any (suspiciousTerms)
| project Timestamp, DeviceName, AccountUpn=InitiatingProcessAccountUpn, FileName, ProcessCommandLine, InitiatingProcessFileName, InitiatingProcessCommandLine, SHA256
| order by Timestamp descSource: KQLMSPress/definitive-guide-kql Chapter 5: KQL for Cyber Security/Query Samples. Adapted from endpoint and ransomware hunting themes with common PowerShell indicators.