title: PowerShell Launched With an Encoded Command (-EncodedCommand Prefixes)
id: c90a658a-4717-40f5-afb7-074a7ce0ba97
status: experimental
description: |
  Detects powershell.exe or pwsh.exe launched with -EncodedCommand or one of its
  abbreviations (-e, -ec, -en, -enc…), including with / or a Unicode dash.
references:
  - https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_pwsh
  - https://attack.mitre.org/techniques/T1059/001/
author: PurpleLog
date: 2026-10-17
tags:
  - attack.execution
  - attack.t1059.001
  - attack.stealth
  - attack.t1027.010
logsource:
  category: process_creation
  product: windows
detection:
  selection_img:
    - Image|endswith:
        - '\powershell.exe'
        - '\pwsh.exe'
    # A renamed powershell.exe still carries its original name in the PE metadata
    - OriginalFileName:
        - 'PowerShell.EXE'
        - 'pwsh.dll'
  selection_cli:
    # windash expands "-" to /, –, — and ―
    CommandLine|windash|contains:
      - ' -e '
      - ' -ec '
      - ' -en'
  condition: all of selection_*
falsepositives:
  - Deployment and monitoring agents that ship encoded scripts (SCCM, Intune, some RMM tools)
level: medium
