PowershellCommand footprint
Description
Find all machines running a given Powersehll cmdlet. This covers all Powershell commands executed in the Powershell engine by any process.
Query · kql
let powershellCommandName = "Invoke-RickAscii";
DeviceEvents
| where ActionType == "PowerShellCommand"
// This filter improves query performance, as it avoids needing to parse Command from all rows and only then applying a filter
| where AdditionalFields contains powershellCommandName
// Extract the powershell command name from the Command field in the AdditionalFields JSON column
| project PowershellCommand=extractjson("$.Command", AdditionalFields, typeof(string)), InitiatingProcessCommandLine, InitiatingProcessParentFileName, Timestamp, DeviceId
// Do an exact case-insensitive match on the command name field
| where PowershellCommand =~ powershellCommandName