[BUG] Claude Code tries to test PowerShell script syntax without execution by running "pwsh.exe -File xxx -NoExecute -WhatIf" but NoExecute and WhatIf are not pwsh.exe command line options

Resolved 💬 3 comments Opened Sep 8, 2025 by TimMillerDyck-KindredCreditUnion Closed Jan 8, 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?

When Claude Code tries to test PowerShell script syntax after it makes changes, it suggests running the command "pwsh.exe -File xxx -NoExecute -WhatIf" where xxx is the name of the PowerShell script file. However, both the NoExecute and WhatIf command-line options are halucinated. Neither of these actually exist as pwsh.exe command-line options.

Sample output from Claude:

Perfect! Let me perform a syntax validation of the script to ensure all the changes are working correctly:

● Bash(pwsh.exe -File "xxx" -NoExecute -WhatIf)
  ⎿  Running…

Bash command

  pwsh.exe -File "xxx" -NoExecute -WhatIf
  Test PowerShell script syntax without execution  

Here are the valid pwsh.exe options for the current PowerShell 7.5.2 version.

Usage: pwsh[.exe] [-Login] [[-File] <filePath> [args]]
                  [-Command { - | <script-block> [-args <arg-array>]
                                | <string> [<CommandParameters>] } ]
                  [-CommandWithArgs <string> [<CommandParameters>]
                  [-ConfigurationName <string>] [-ConfigurationFile <filePath>]
                  [-CustomPipeName <string>] [-EncodedCommand <Base64EncodedCommand>]
                  [-ExecutionPolicy <ExecutionPolicy>] [-InputFormat {Text | XML}]
                  [-Interactive] [-MTA] [-NoExit] [-NoLogo] [-NonInteractive] [-NoProfile]
                  [-NoProfileLoadTime] [-OutputFormat {Text | XML}]
                  [-SettingsFile <filePath>] [-SSHServerMode] [-STA]
                  [-Version] [-WindowStyle <style>]
                  [-WorkingDirectory <directoryPath>]

       pwsh[.exe] -h | -Help | -? | /?

What Should Happen?

Claude Code should not call pwsh.exe with command-line parameters that do not actually exist.

Error Messages/Logs

Steps to Reproduce

  1. Create a PowerShell script
  2. Have Claude Code make changes
  3. Observe what Claude Code suggests to validate the changes by running the script using pwsh.exe

Claude Model

Sonnet (default)

Is this a regression?

I don't know

Last Working Version

_No response_

Claude Code Version

1.0.108

Platform

Anthropic API

Operating System

Windows

Terminal/Shell

IntelliJ IDEA terminal

Additional Information

_No response_

View original on GitHub ↗

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