Skip to content
Threat Feed
medium advisory

Detection of PowerShell Executing Batch Scripts

Adversaries often abuse PowerShell to invoke batch files, allowing for sequential command execution and complex logic within the Windows environment.

Adversaries frequently leverage the Windows command shell and PowerShell to execute batch scripts (typically with .bat or .cmd extensions) as part of their post-exploitation activities. This technique allows attackers to run lists of sequential commands, perform repetitive system tasks, or implement complex logic such as conditionals and loops under the context of an existing PowerShell session. Because batch files can be used to facilitate both legitimate administrative tasks and malicious activity, monitoring the invocation of these scripts via PowerShell is essential for identifying unauthorized execution patterns. Detection engineers should focus on PowerShell Script Block Logging (Event ID 4104) to capture the full command context when Start-Process is used to trigger these scripts.

Impact

Successful execution of malicious batch scripts can lead to full system compromise, lateral movement, or the execution of additional staged payloads. If undetected, attackers can maintain persistence or execute automated tasks across multiple systems within an enterprise network.

Recommendation

  • Enable Windows PowerShell Script Block Logging (Event ID 4104) across all endpoints to ensure the full content of executed scripts is captured in logs.
  • Deploy the provided Sigma rule to your SIEM to monitor for PowerShell scripts attempting to launch .bat or .cmd files.
  • Establish a baseline for administrative scripts used in your environment to tune out false positives originating from legitimate system management activity.

Immediate actions

Deploy Sigma detection rule to SIEM

Detection Engineering 72h

Mitigations

Enforce PowerShell Constrained Language Mode where appropriate

medium_term IT Operations

General script abuse

Detection coverage 1

Detect PowerShell Executing Batch Script

medium

Detects the use of Start-Process in PowerShell to execute .bat or .cmd files, a common technique for command shell abuse.

sigma tactics: execution techniques: T1059.003 sources: ps_script, windows

Detection queries are available on the platform. Get full rules →