Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Aug 12, 2025

The extension previously hardcoded the use of pwsh (PowerShell 7+) as the PowerShell executable, which would fail in environments where only Windows PowerShell 5.1 (powershell.exe) is available. This is common in enterprise Windows environments where PowerShell 7+ hasn't been deployed yet.

Changes Made

  • Replaced hardcoded executable: Removed the static POWERSHELL_EXECUTABLE = 'pwsh' constant
  • Added dynamic detection: Implemented detectPowerShellExecutable() method that:
    1. First attempts to use pwsh (PowerShell 7+)
    2. Falls back to powershell (Windows PowerShell 5.1) if pwsh is unavailable
    3. Caches the detected executable to avoid repeated detection calls
  • Enhanced error handling: Added testExecutable() method with improved error messages
  • Updated all execution paths: Modified executeScript() and isPowerShellAvailable() methods to use the fallback logic

Example Behavior

Before (fails on Windows without PowerShell 7+):

Error: spawn pwsh ENOENT

After (automatically falls back):

Using PowerShell executable: powershell
Detected PowerShell version using powershell: 5.1.19041.4648

Testing

  • ✅ Verified compatibility with PowerShell 7+ environments (existing functionality preserved)
  • ✅ Validated fallback logic for Windows PowerShell scenarios
  • ✅ Confirmed localization parsing continues to work correctly
  • ✅ Extension builds and packages successfully

The extension now works seamlessly across different Windows PowerShell configurations without requiring users to install PowerShell 7+.

Fixes #6.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI changed the title [WIP] Add Windows PowerShell fall back support Add Windows PowerShell fallback support when pwsh is unavailable Aug 12, 2025
Copilot AI requested a review from HeyItsGilbert August 12, 2025 14:34
@HeyItsGilbert
Copy link
Contributor

@copilot please update the changelog also

…ility

Co-authored-by: HeyItsGilbert <615265+HeyItsGilbert@users.noreply.github.com>
Co-authored-by: HeyItsGilbert <615265+HeyItsGilbert@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Aug 12, 2025

@copilot please update the changelog also

Updated CHANGELOG.md with the PowerShell fallback support feature. Added entry under "Unreleased" section documenting the new automatic detection and fallback functionality that enables compatibility with Windows PowerShell 5.1 environments. (commit 38e495c)

@HeyItsGilbert HeyItsGilbert marked this pull request as ready for review August 12, 2025 15:23
@HeyItsGilbert HeyItsGilbert merged commit 94e7a95 into main Aug 12, 2025
1 of 4 checks passed
@HeyItsGilbert HeyItsGilbert deleted the copilot/fix-6 branch August 12, 2025 17:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Windows PowerShell fall back support

2 participants