claude-code - 💡(How to fix) Fix [BUG] Windows: pwsh.exe stdout/stderr not captured by PowerShell tool or via Bash tool, both via app alias and direct path; powershell.exe works fine in same session.

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

Error Message

Error Messages/Logs

"/c/Program Files/PowerShell/7/pwsh.exe" -NoProfile -NonInteractive -Command 'Write-Host HOST; Write-Output OUT; [Console]::Out.WriteLine("CON_OUT"); [Console]::Error.WriteLine("CON_ERR")' 2>&1 PowerShell tool returns the literal message (PowerShell completed with no output) — every time, for every command, regardless of which stream (Write-Output, Write-Host, [Console]::Out.WriteLine, [Console]::Error.WriteLine).

Fix Action

Fix / Workaround

Workaround

Code Example

N/A
RAW_BUFFERClick to expand / collapse

Preflight Checklist

  • I have searched existing issues and this hasn't been reported yet
  • This is a single bug report (please file separate reports for different bugs)
  • I am using the latest version of Claude Code

What's Wrong?

Windows: pwsh.exe stdout/stderr not captured by PowerShell tool or via Bash tool, both via app alias and direct path; powershell.exe works fine in same session.

What Should Happen?

pwsh should return results to stdout

Error Messages/Logs

N/A

Steps to Reproduce

Environment

Windows 11 Enterprise (10.0.26200) Claude Code (VS Code extension), PowerShell tool reports model is Opus 4.7 PowerShell 7.6.1 (Core), at C:\Program Files\PowerShell\7\pwsh.exe — also installed as MS Store package Microsoft.PowerShell_7.6.1.0_x64__8wekyb3d8bbwe (App Execution Alias in WindowsApps) Windows PowerShell 5.1.26100.8115 (Desktop) also present Issue reproduces with hooks both present and absent Steps to reproduce

In a Windows session with PS 7.6.1 installed, ask Claude Code to run any of the following via the PowerShell tool:

Write-Output "hello"

$PSVersionTable.PSVersion

Get-Date Or via the Bash tool, invoke pwsh directly:

"/c/Program Files/PowerShell/7/pwsh.exe" -NoProfile -NonInteractive -Command 'Write-Host HOST; Write-Output OUT; [Console]::Out.WriteLine("CON_OUT"); [Console]::Error.WriteLine("CON_ERR")' 2>&1 echo "EXIT=$?" Expected

The strings hello, 7.6.1, HOST, OUT, CON_OUT, CON_ERR etc. appear in tool output.

Actual

PowerShell tool returns the literal message (PowerShell completed with no output) — every time, for every command, regardless of which stream (Write-Output, Write-Host, [Console]::Out.WriteLine, [Console]::Error.WriteLine). Bash → pwsh.exe returns empty stdout/stderr with EXIT=0. The pwsh process does run — verified by having pwsh write a file: Set-Content -Path $env:TEMP\probe.txt -Value "$PID $($PSVersionTable.PSVersion)" succeeds and the file contains 32336 7.6.1. So pwsh executes correctly; only its stdio doesn't reach the harness. Control (works)

Same session, powershell.exe (Windows PowerShell 5.1) via Bash tool returns output fine:

powershell.exe -NoProfile -Command '$PSVersionTable.PSVersion.ToString(); $PSVersionTable.PSEdition'

→ 5.1.26100.8115 / Desktop

So the harness's stdio capture isn't broken in general — the bug is specific to pwsh.exe (PowerShell 7).

Workaround

Have pwsh write output to a temp file, then read it with the Read tool. Functional but adds two tool calls per probe.

Hooks ruled out

User has PostToolUse hooks configured (no matcher → fires on every tool). Hook uses the proper hookSpecificOutput.additionalContext JSON schema, not raw stdout. Same hook fires on Bash tool calls in the same session without affecting Bash output, so the hook is not displacing stdout.

Claude Model

Opus

Is this a regression?

I don't know

Last Working Version

No response

Claude Code Version

Claude Code 2.1.114 CLI

Platform

Anthropic API

Operating System

Windows

Terminal/Shell

PowerShell

Additional Information

No response

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

claude-code - 💡(How to fix) Fix [BUG] Windows: pwsh.exe stdout/stderr not captured by PowerShell tool or via Bash tool, both via app alias and direct path; powershell.exe works fine in same session.