← Back to SOC feed Coverage →

PowershellCommand footprint

kql MEDIUM Azure-Sentinel
DeviceEvents
huntingmicrosoftofficialpowershell
This rule was pulled from an open-source repository and enriched with AI. Validate in a test environment before deploying to production.
View original rule at Azure-Sentinel →
Retrieved: 2026-05-20T11:00:00Z · Confidence: medium

Hunt Hypothesis

Adversaries may use PowerShell cmdlets to execute malicious scripts or establish persistence, making this behavior indicative of potential compromise. SOC teams should proactively hunt for unusual or unexpected PowerShell command usage in Azure Sentinel to identify and mitigate early-stage threats.

KQL Query

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

Analytic Rule Definition

id: 261d966b-5c1a-4d28-b444-3a8caac6246e
name: PowershellCommand footprint
description: |
  Find all machines running a given Powersehll cmdlet.
  This covers all Powershell commands executed in the Powershell engine by any process.
requiredDataConnectors:
- connectorId: MicrosoftThreatProtection
  dataTypes:
  - DeviceEvents
query: |
  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

Required Data Sources

Sentinel TableNotes
DeviceEventsEnsure this data connector is enabled

References

False Positive Guidance

Original source: https://github.com/Azure/Azure-Sentinel/blob/main/Hunting Queries/Microsoft 365 Defender/Execution/PowershellCommand footprint.yaml