Skip to content

[Bug] Exec tool corrupts PowerShell pipeline variables on Windows - \ stripped, -f operator broken #35807

@henrybottter

Description

@henrybottter

Bug Report

Supersedes: #6443 (locked — not resolved. Confirmed by 2 independent users)

Expected behavior

Exec tool passes PowerShell commands to the shell verbatim. Pipeline variables and operators work as expected.

Observed behavior

Exec tool corrupts PowerShell commands on Windows when passed inline:

  • \\ (pipeline variable) is stripped or mangled
  • -f\ string format operator fails with parse errors
  • \ForEach-Object, \Where-Object\ fail silently or produce wrong output

Commands work correctly when written to a .ps1 file and executed with \powershell -File.

Environment

Root cause (suspected)

Exec tool routes through cmd.exe, which mangles \$, backticks, and double-quotes before PowerShell sees them.

Workaround

Write command to temp .ps1 file, execute with \powershell -File script.ps1, clean up. Required for every non-trivial inline PowerShell command. Adds 2-3 extra tool calls per operation.

Impact

At our current usage rate (~20 exec calls/hour), the workaround adds significant token overhead. Every Windows agent deployment is affected.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions