Skip to content

[BUG] Windows: PowerShell tool returns Exit 1 silently — pwsh works fine outside CC[Bug] Windows: PowerShell tool returns Exit 1 silently — pwsh works fine outside CC #60664

Description

@Oriorart

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?

Description

On Claude Code Desktop 2.1.142 (Windows 11), every invocation of the native PowerShell tool returns Exit code 1 with no output and no error message, even for trivial commands like "hello" or Write-Output "test".

The bug is persistent across:

  • Closing and reopening Claude Code Desktop
  • Full Windows reboot

The Bash tool works normally throughout, and PowerShell itself is fully functional when invoked from the Bash tool (pwsh -Command "..." or powershell -Command "...").

Environment

  • OS: Windows 11 (build 26100.8457)
  • Claude Code Desktop version: 2.1.142 (auto-updated, latest available)
  • CLI npm version: 2.1.138 (@anthropic-ai/claude-code published 2.1.144)
  • pwsh version: 7.6.1 (installed via Microsoft Store — Microsoft.PowerShell_7.6.1.0_x64__8wekyb3d8bbwe)
  • Windows PowerShell version: 5.1.26100.8457
  • Session entrypoint (from ~/.claude/sessions/<pid>.json): claude-desktop

Steps to reproduce

  1. Open Claude Code Desktop on Windows 11
  2. Invoke the PowerShell tool with any command, e.g.:
    "hello"
    

What Should Happen?

Result: Exit code 1, no stdout, no stderr
Expected behavior
Output of the command (e.g. hello).

Actual behavior
Exit code 1, no output at all. The error is silent — nothing surfaces to the user beyond the bare exit code.

Error Messages/Logs

Steps to Reproduce

Workaround (validated)
Invoking PowerShell through the Bash tool works perfectly:

pwsh -Command "Write-Output 'test'" # → test
pwsh -NonInteractive -NoProfile -Command "..." # → OK
powershell -Command "Get-Service ssh-agent" # → OK

So the issue is specifically with how claude.exe invokes pwsh internally, not with PowerShell itself.

Investigation done
pwsh.exe and powershell.exe are both accessible and functional from Bash tool
All PowerShell $PROFILE.* paths return Test-Path = False (no profiles installed, not the cause)
PATH includes both /c/WINDOWS/System32/WindowsPowerShell/v1.0 and /c/Users//AppData/Local/Microsoft/WindowsApps
~/.claude/shell-snapshots/ contains only snapshot-bash-.sh files — no PowerShell snapshot is ever generated, even after many tool invocations
The cache directory ~/AppData/Local/Microsoft/PowerShell/7.6.1/ contains a StartupProfileData-NonInteractive file that is regenerated normally on direct pwsh invocations from Bash
winget upgrade Microsoft.PowerShell reports "no newer version available"
pwsh works in all modes when invoked from Bash: -NoProfile, -NonInteractive, -NoProfile -NonInteractive, with .exe or via execution alias
Hypothesis
Claude Code Desktop on Windows appears to fail at creating its shell-snapshot for PowerShell at session initialization. The absence of any snapshot-pwsh-
.ps1 (or similar) in ~/.claude/shell-snapshots/ suggests the snapshot generation crashes silently, and all subsequent PowerShell tool invocations inherit that broken state.

Impact
Low/medium. The Bash → pwsh workaround is trivial. But:

Users not aware of the workaround will think PowerShell is broken on their system
Verbose syntax overhead (pwsh -Command "..." instead of native PowerShell tool)
Project-level settings.json permissions for PowerShell(...) patterns become useless until the bug is fixed

Claude Model

Opus

Is this a regression?

Yes, this worked in a previous version

Last Working Version

CC Desktop = 2.1.142

Claude Code Version

2.1.138

Platform

Anthropic API

Operating System

Windows

Terminal/Shell

Terminal.app (macOS)

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions