Operator On The Wire
Join
← Back to Knowledge Base
BLUE TEAM / THREAT HUNT / WINDOWS / EXECUTION

PowerShell

This note documents detection patterns related to PowerShell Abuse within Windows environments.


Direct Indicators

LogEvent IDMeaningForensic ValueNotes
PowerShell4104Script block loggingCriticalHighest-value PowerShell content visibility.
PowerShell4103Module loggingCriticalCaptures cmdlet execution and parameters.
Security4688Process creationCriticalDetects PowerShell launch arguments and parent process.
Sysmon1Process creationCriticalBest execution source for PowerShell lineage and hashes.
Sysmon3Network connectionHighOutbound activity from PowerShell process.
Sysmon11File createHighPayload drop, temp scripts, decoded output.
Sysmon22DNS queryHighDomain resolution during retrieval or beaconing.
Security400 / 403Engine start / stopMediumSession lifecycle context.

Indirect Indicators

IndicatorWhat To Look ForForensic ValueNotes
EncodedCommand used-enc, -EncodedCommandCriticalStrong attacker indicator.
Hidden window flags-w hidden, -nopCriticalCommon stealth execution.
Download cradleInvoke-WebRequest, DownloadString, WebClientCriticalClassic staging pattern.
Office or LOLBIN parentwinword, mshta, regsvr32CriticalStrong malicious chain.
PowerShell spawning LOLBINscertutil, bitsadmin, rundll32HighMulti-stage execution.
PowerShell under SYSTEM unexpectedlyService or task abuseHighPersistence or privesc clue.
Short-lived PowerShell + networkBeacon stagingCriticalCommon implant launch.

Common Tools

ToolUsage
powershell.exeNative execution engine
pwsh.exePowerShell Core
PowerViewReconnaissance
EmpireOffensive framework
Cobalt StrikePayload staging
NishangOffensive scripts
custom scriptsIn-memory execution

Relevant Artifacts

  • PowerShell Event IDs 4103, 4104
  • Security Event ID 4688
  • Sysmon Event IDs 1, 3, 11, 22
  • PowerShell history:
    • %APPDATA%\Microsoft\Windows\PowerShell\PSReadLine\ConsoleHost_history.txt
  • Prefetch: POWERSHELL.EXE
  • Amcache / ShimCache
  • MFT / USN for scripts
  • EDR script lineage

MITRE ATT&CK References

  • T1059.001 PowerShell
  • T1105 Ingress Tool Transfer
  • T1027 Obfuscated Files or Information

Decision Tree

  1. Which PowerShell launched?

    • powershell.exe
    • pwsh.exe
  2. Command suspicious?

    • Encoded?
    • Hidden?
    • Downloading?
  3. Parent suspicious?

    • Office
    • Browser
    • Service
  4. Follow-up activity?

    • Network
    • File create
    • Child process
  5. Expand:

    • Persistence
    • Credential access
    • Lateral movement
  6. Scope:

    • Single script
    • Framework use
    • Multi-host execution

Example Detection Templates

KQL

SecurityEvent
| where EventID == 4688
| where NewProcessName has "powershell.exe"
| project TimeGenerated, Computer, Account, CommandLine, ParentProcessName
PowerShell
| where EventID == 4104
| project TimeGenerated, Computer, ScriptBlockText

EQL

process where process.name == "powershell.exe"
sequence by host.name with maxspan=5m
  [ process where process.name == "powershell.exe" ]
  [ network where process.name == "powershell.exe" ]

Sigma

title: Suspicious PowerShell Abuse
id: 6b4f2a91-powershell-abuse
status: experimental
description: Detects suspicious PowerShell execution patterns
references:
  - https://attack.mitre.org/
author: Vergil
date: 2026-03-07
logsource:
  product: windows
  service: security
detection:
  selection:
    NewProcessName|endswith: '\powershell.exe'
  keywords:
    CommandLine|contains:
      - '-enc'
      - '-nop'
      - 'DownloadString'
      - 'Invoke-WebRequest'
  condition: selection and keywords
fields:
  - CommandLine
  - ParentProcessName
falsepositives:
  - Administrative automation
level: high
tags:
  - attack.execution
  - attack.t1059.001

Mitigation & Hardening

Control AreaMitigationEffectivenessNotes
Script block loggingEnable 4104CriticalHighest-value content source
Module loggingEnable 4103CriticalCaptures cmdlet detail
Constrained language modeRestrict advanced featuresHighReduces abuse
AppLocker / WDACLimit PowerShell executionHighStrong control
Parent-child monitoringAlert on suspicious launch chainsCriticalEssential triage