PowerShell MSIX pwsh.exe returns Access Denied when launched by multiple terminal applications
Prerequisites
- Write a descriptive title.
- Make sure you are able to repro it on the latest released version
- Search the existing issues.
- Refer to the FAQ.
- Refer to Differences between Windows PowerShell 5.1 and PowerShell.
Steps to reproduce
- Install PowerShell 7.6.6 using WinGet:
winget install --id Microsoft.PowerShellThe WinGet package installs the MSIX variant. Verify that pwsh.exe resolves through the Windows App Execution Alias:
where.exe pwsh
(Get-Command pwsh).SourceExpected result:
C:\Users\<username>\AppData\Local\Microsoft\WindowsApps\pwsh.exe- Open Windows Terminal and start PowerShell 7:
pwshLeave the PowerShell session running.
- Open GitHub Copilot App and open a terminal in a project/worktree.
GitHub Copilot App attempts to launch PowerShell using a command similar to:
C:\Users\<username>\AppData\Local\Microsoft\WindowsApps\pwsh.exe --nologo -ExecutionPolicy Bypass -NoExit -Command ". '<path>\terminal-integration\shellIntegration.ps1'"- The GitHub Copilot terminal fails to start with:
Failed to spawn PTY command: CreateProcessW ... failed: Access is denied. (os error 5)- The reverse sequence also reproduces the problem. If the GitHub Copilot terminal is started first, then attempting to launch PowerShell from Windows Terminal fails with:
[error 2147942405 (0x80070005) when launching "C:\Users\<username>\AppData\Local\Microsoft\WindowsApps\pwsh.exe" --nologo]- Remove the MSIX installation and install the MSI version of the same PowerShell release:
winget uninstall --id Microsoft.PowerShellThen install the MSI package of PowerShell 7.6.6.
winget install --id Microsoft.PowerShell --source winget --installer-type wixAfter installation:
where.exe pwshresolves to:
C:\Program Files\PowerShell\7\pwsh.exe- Repeat the same Windows Terminal ↔ GitHub Copilot App test.
Both applications can now launch independent PowerShell processes concurrently without errors.
The PowerShell version remains 7.6.6 in both cases, so the difference is the installation/package type and executable path rather than the PowerShell version itself.
Expected behavior
Independent terminal applications should be able to launch separate PowerShell processes concurrently within the same Windows user session.
An existing PowerShell process launched by one terminal application should not prevent another terminal application from creating a new `pwsh.exe` process.
The MSIX/App Execution Alias at:
%LOCALAPPDATA%\Microsoft\WindowsApps\pwsh.exe
should behave equivalently to the normal PowerShell executable when used to create independent processes.Actual behavior
When PowerShell 7.6.6 is installed as the MSIX package, launching `pwsh.exe` from a second terminal application fails with `ERROR_ACCESS_DENIED (5)` / `0x80070005` if another terminal application already has an MSIX-installed PowerShell process running.
The failure occurs in both directions:
* Windows Terminal → GitHub Copilot App: Copilot fails to create the PowerShell process.
* GitHub Copilot App → Windows Terminal: Windows Terminal fails to create the PowerShell process.
The failure occurs before PowerShell starts executing commands. In the GitHub Copilot case, `CreateProcessW` fails while attempting to create the process, so `shellIntegration.ps1` is not reached.
Installing the MSI version of the exact same PowerShell release changes the executable to:
C:\Program Files\PowerShell\7\pwsh.exe
and the problem disappears. Windows Terminal and GitHub Copilot App can then run PowerShell simultaneously.
This makes the MSIX/App Execution Alias path a significant differentiating factor in the reproduction.Error details
GitHub Copilot App:
Failed to spawn PTY command: CreateProcessW `"C:\Users\<username>\AppData\Local\Microsoft\WindowsApps\pwsh.exe --nologo -ExecutionPolicy Bypass -NoExit -Command ". '<path>\terminal-integration\shellIntegration.ps1>'"` failed: Access is denied. (os error 5)
Windows Terminal:
[error 2147942405 (0x80070005) when launching "C:\Users\<username>\AppData\Local\Microsoft\WindowsApps\pwsh.exe" --nologo]
The important error is:
ERROR_ACCESS_DENIED (5)
0x80070005
The error is returned while creating the process rather than from a PowerShell command executed inside the new process.Environment data
PS> $PSVersionTable | Format-List
Name : PSVersion
Value : 7.6.6
Name : PSEdition
Value : Core
Name : GitCommitId
Value : 7.6.6
Name : OS
Value : Microsoft Windows 10.0.26200
Name : Platform
Value : Win32NT
Name : PSCompatibleVersions
Value : {1.0, 2.0, 3.0, 4.0…}
Name : PSRemotingProtocolVersion
Value : 2.4
Name : SerializationVersion
Value : 1.1.0.1
Name : WSManStackVersion
Value : 3.0
MSIX installation:
PS> where.exe pwsh
C:\Users\<username>\AppData\Local\Microsoft\WindowsApps\pwsh.exe
PS> (Get-Command pwsh).Source
C:\Users\<username>\AppData\Local\Microsoft\WindowsApps\pwsh.exe
The MSIX package was installed using WinGet:
winget install --id Microsoft.PowerShell
After replacing the MSIX installation with the MSI installation of the same PowerShell 7.6.6 release:
winget install --id Microsoft.PowerShell --source winget --installer-type wix
PS> where.exe pwsh
C:\Program Files\PowerShell\7\pwsh.exe
The MSI installation does not exhibit the concurrent-launch failure.Visuals
No response
Related issues
There are several related reports involving PowerShell's MSIX/App Execution Alias and pwsh.exe under %LOCALAPPDATA%\Microsoft\WindowsApps:
#27565 — Tracking: MSIX packaging gaps for PowerShell 7 #27603 — PowerShell from Microsoft Store is causing problems on Codex GitHub/App#2820 — Terminal failed to start with "Access is denied" microsoft/terminal#20201 — error 0x80070780 when starting pwsh.exe OpenAI/Codex#38222 — Windows sandbox: restricted token cannot enumerate or execute under the user profile
Windows Terminal #20201 is particularly relevant because it involves PowerShell launched through the MSIX App Execution Alias on Windows build 26200, and a Terminal maintainer specifically identified the App Execution Alias as a likely culprit.
The failure described in this report is different: it occurs during normal process creation between independent terminal applications when one PowerShell process is already running. The same PowerShell 7.6.6 installation works correctly when installed via MSI, where pwsh.exe resolves to C:\Program Files\PowerShell\7\pwsh.exe.
I am not assuming these reports have the same root cause, but the shared MSIX/App Execution Alias path and process-launch failures may be related.
Source: PowerShell/PowerShell