I had some weird issues with PowerShell which I think I have now fixed:
Issue
AI Agents in Cursor were unable to capture output from PowerShell commands, resulting in exit code 1 and no visible output, despite commands executing successfully when run manually.
Environment
- Windows 11 Pro N (Version 10.0.26100)
- PowerShell 7.5.0 (installed via WinGet)
- Cursor AI IDE
Solution Steps
-
Verify PowerShell Installations
- Confirmed Windows PowerShell 5.1 at:
C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe
- Confirmed PowerShell 7.5.0 at:
C:\Users\<removed>\AppData\Local\Microsoft\WinGet\Links\pwsh.exe
- Confirmed Windows PowerShell 5.1 at:
-
Configure Cursor Settings
- Open Cursor Settings (JSON)
- Location:
%APPDATA%\Cursor\User\settings.json
- Add PowerShell 7 profile and set as default:
{ "terminal.integrated.profiles.windows": { "PowerShell 7": { "path": "C:\\Users\\<removed>\AppData\\Local\\Microsoft\\WinGet\\Links\\pwsh.exe", "icon": "terminal-powershell", "args": [] } }, "terminal.integrated.defaultProfile.windows": "PowerShell 7" }
-
Terminal Preview Setting
- Disabled “Use preview box for terminal Ctrl+K” in Cursor settings
- This setting affects how responses are streamed to the shell
-
Restart Required
- Close all terminal instances
- Restart Cursor to apply changes
Verification
After implementing these changes:
- PowerShell 7.5.0 runs as the default shell
- AI Agents can successfully:
- Execute PowerShell commands
- Capture command output
- Use advanced PowerShell 7 features
- Process pipeline operations
- Handle object manipulation and formatting
Notes
- The fix ensures AI Agents can fully interact with PowerShell 7
- Commands now return proper exit codes and visible output
- Terminal integration supports all PowerShell features including advanced formatting and object manipulation
- Some PSReadLine diagnostic messages may appear but don’t affect functionality
P.S. there are a lot of options in Settings when you search for terminal.integrated - I think that others with different issues might find something in there to help