T1059.001
PowerShell
Adversaries may abuse PowerShell commands and scripts for execution. PowerShell is a powerful interactive command-line interface and scripting environment included in the Windows operating system. Adversaries can use PowerShell to perform a number of actions, including discovery of information and execution of code. PowerShell can also be used to download and run executables from the Internet, which can be executed from disk or in memory without touching disk.
Microsoft Sentinel / Defender
kusto
let SuspiciousPatterns = dynamic([
"-EncodedCommand", "-enc ", "-e ", "-ec ",
"Invoke-WebRequest", "IWR ", "Invoke-RestMethod",
"Net.WebClient", "DownloadString", "DownloadFile", "DownloadData",
"Start-BitsTransfer",
"AmsiUtils", "amsiInitFailed", "SetProtectionLevel",
"Invoke-Expression", "IEX(", "IEX ",
"-ExecutionPolicy Bypass", "-ep bypass", "-ep unrestricted",
"-WindowStyle Hidden", "-w hidden", "-windowstyle h",
"[Convert]::FromBase64String", "[System.Convert]::FromBase64String",
"Invoke-Mimikatz", "Invoke-Shellcode",
"New-Object IO.MemoryStream", "IO.Compression",
"bitsadmin", "certutil -urlcache"
]);
DeviceProcessEvents
| where Timestamp > ago(24h)
| where FileName =~ "powershell.exe" or FileName =~ "pwsh.exe"
| where ProcessCommandLine has_any (SuspiciousPatterns)
| extend EncodedCmd = ProcessCommandLine has_any ("-EncodedCommand", "-enc ", "-e ", "-ec ")
| extend DownloadCradle = ProcessCommandLine has_any ("Invoke-WebRequest", "Net.WebClient", "DownloadString", "DownloadFile", "IWR ", "Start-BitsTransfer")
| extend AmsiBypass = ProcessCommandLine has_any ("AmsiUtils", "amsiInitFailed", "SetProtectionLevel")
| extend PolicyBypass = ProcessCommandLine has_any ("-ExecutionPolicy Bypass", "-ep bypass")
| extend HiddenWindow = ProcessCommandLine has_any ("-WindowStyle Hidden", "-w hidden")
| project Timestamp, DeviceName, AccountName, FileName, ProcessCommandLine,
InitiatingProcessFileName, InitiatingProcessCommandLine,
EncodedCmd, DownloadCradle, AmsiBypass, PolicyBypass, HiddenWindow
| sort by Timestamp desc high severity
high confidence
Data Sources
Process: Process Creation Command: Command Execution Microsoft Defender for Endpoint
Required Tables
DeviceProcessEvents
False Positives
- System administrators using encoded commands for legitimate automation scripts
- Software deployment tools (SCCM, Intune) that use encoded PowerShell for installation scripts
- Monitoring agents that use Invoke-WebRequest to check URLs or download updates
- IT automation platforms (Ansible WinRM, Chef, Puppet) executing PowerShell remotely
Last updated: 2026-04-13 Research depth: deep
References (8)
- https://attack.mitre.org/techniques/T1059/001/
- https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_logging
- https://learn.microsoft.com/en-us/defender-endpoint/advanced-hunting-deviceprocessevents-table
- https://docs.splunk.com/Documentation/SplunkCloud/latest/SearchReference/CommonStatsFunctions
- https://github.com/redcanaryco/atomic-red-team/blob/master/atomics/T1059.001/T1059.001.md
- https://github.com/SigmaHQ/sigma/tree/master/rules/windows/powershell
- https://www.mandiant.com/resources/blog/obfuscation-wild-targeted-attackers-lead-way-evasion
- https://s3cur3th1ssh1t.github.io/Powershell-and-the-NET-AMSI-Interface/
Unlock Pro Content
Get the full detection package for T1059.001 including response playbook, investigation guide, and atomic red team tests.
Response PlaybookInvestigation GuideHunting QueriesAtomic Red Team TestsTuning Guidance