PowerShell launched with an encoded command
Finds PowerShell processes started with a Base64 encoded command (-e, -enc, -EncodedCommand). This is a common way attackers hide what a script does, though some admin tools use it legitimately.
DeviceProcessEvents
| where Timestamp > ago(7d)
| where FileName in~ ("powershell.exe", "pwsh.exe")
| where ProcessCommandLine matches regex @"(?i)\s-e[a-z]*\s+[a-z0-9+/=]{20,}"
| project Timestamp, DeviceName, AccountName, ProcessCommandLine,
InitiatingProcessFileName, InitiatingProcessCommandLine
| sort by Timestamp desc
