← Back to SOC feed Coverage →

powershell-activity-after-email-from-malicious-sender

kql MEDIUM Azure-Sentinel
DeviceProcessEventsEmailEvents
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-20T23:00:01Z · Confidence: medium

Hunt Hypothesis

Powershell-activity-after-email-from-malicious-sender detects potential PowerShell-based malware execution triggered by emails from known malicious senders, indicating possible initial compromise. SOC teams should proactively hunt for this behavior in Azure Sentinel to identify and mitigate early-stage adversarial activity before further damage occurs.

KQL Query

//Find PowerShell activities right after email was received from malicious sender
let x=EmailEvents
| where SenderFromAddress =~ "[email protected]"
| project TimeEmail = Timestamp, Subject, SenderFromAddress, AccountName = tostring(split(RecipientEmailAddress, "@")[0]);
x
| join (
DeviceProcessEvents
| where FileName =~ "powershell.exe"
//| where InitiatingProcessParentFileName =~ "outlook.exe"
| project TimeProc = Timestamp, AccountName, DeviceName, InitiatingProcessParentFileName, InitiatingProcessFileName, FileName, ProcessCommandLine
) on AccountName 
| where (TimeProc - TimeEmail) between (0min.. 30min)

Analytic Rule Definition

id: 0605673c-8363-40b3-bbe2-ac1a2c17d116
name: powershell-activity-after-email-from-malicious-sender
description: |
  Malicious emails often contain documents and other specially crafted attachments that run PowerShell commands to deliver additional payloads. If you are aware of emails coming from a known malicious sender, you can use this query to list and review PowerShell activities that occurred within 30 minutes after an email was received from the sender .
requiredDataConnectors:
- connectorId: MicrosoftThreatProtection
  dataTypes:
  - EmailEvents
  - DeviceProcessEvents
tactics:
- Execution
query: |
  //Find PowerShell activities right after email was received from malicious sender
  let x=EmailEvents
  | where SenderFromAddress =~ "[email protected]"
  | project TimeEmail = Timestamp, Subject, SenderFromAddress, AccountName = tostring(split(RecipientEmailAddress, "@")[0]);
  x
  | join (
  DeviceProcessEvents
  | where FileName =~ "powershell.exe"
  //| where InitiatingProcessParentFileName =~ "outlook.exe"
  | project TimeProc = Timestamp, AccountName, DeviceName, InitiatingProcessParentFileName, InitiatingProcessFileName, FileName, ProcessCommandLine
  ) on AccountName 
  | where (TimeProc - TimeEmail) between (0min.. 30min)

Required Data Sources

Sentinel TableNotes
DeviceProcessEventsEnsure this data connector is enabled
EmailEventsEnsure this data connector is enabled

MITRE ATT&CK Context

References

False Positive Guidance

Original source: https://github.com/Azure/Azure-Sentinel/blob/main/Hunting Queries/Microsoft 365 Defender/Execution/powershell-activity-after-email-from-malicious-sender.yaml