[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.

Resolved 💬 3 comments Opened May 8, 2026 by droushd Closed Jun 6, 2026

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] 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_

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗