Commit 94e7a95
Add Windows PowerShell fallback support when pwsh is unavailable (#7)
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.
<!-- START COPILOT CODING AGENT TIPS -->
---
💡 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](https://gh.io/copilot-coding-agent-tips) in the docs.
---------
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: HeyItsGilbert <615265+HeyItsGilbert@users.noreply.github.com>1 parent 28a5c96 commit 94e7a95
2 files changed
Lines changed: 70 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
12 | 18 | | |
13 | 19 | | |
14 | 20 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
| 11 | + | |
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| |||
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
46 | 103 | | |
47 | 104 | | |
48 | 105 | | |
49 | 106 | | |
50 | 107 | | |
| 108 | + | |
51 | 109 | | |
52 | | - | |
| 110 | + | |
53 | 111 | | |
54 | 112 | | |
55 | 113 | | |
| |||
69 | 127 | | |
70 | 128 | | |
71 | 129 | | |
72 | | - | |
| 130 | + | |
73 | 131 | | |
74 | 132 | | |
| 133 | + | |
| 134 | + | |
75 | 135 | | |
76 | 136 | | |
77 | 137 | | |
| |||
120 | 180 | | |
121 | 181 | | |
122 | 182 | | |
123 | | - | |
| 183 | + | |
124 | 184 | | |
125 | 185 | | |
126 | 186 | | |
| |||
0 commit comments