Skip to content

WinRM configuration "PowerShell.7" points to MS Store version path (7.6.3) instead of MSI path if both are installed. #27701

Description

@PavelZy

Prerequisites

Steps to reproduce

After installing PowerShell 7 via MSI over a Microsoft Store installation, Enter-PSSession -ConfigurationName "PowerShell.7" fails with WSManFault error code 2689860592.
The root cause is inside the registry key HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\WSMAN\Plugin\PowerShell.7. The ConfigXML string contains a hardcoded path to C:\Windows\System32\PowerShell\7.6.3\pwrshplugin.dll, while it should point to C:\Windows\System32\PowerShell\7\pwrshplugin.dll to read the correct RemotePowerShellConfig.txt pointing to C:\Program Files\PowerShell\7.

Fix: Manually edit the registry path in ConfigXML inside the PowerShell.7 key to remove the ".6.3" version suffix.

Expected behavior

After installing PowerShell 7 via the official MSI package on a machine that previously had the Microsoft Store version installed, running `Enter-PSSession -ComputerName "localhost" -ConfigurationName "PowerShell.7"` from a client machine should successfully open a PowerShell 7 remote session. 

The registry key `HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\WSMAN\Plugin\PowerShell.7` under `ConfigXML` should point to the global system path `C:\Windows\System32\PowerShell\7\pwrshplugin.dll`, which references `PSHOMEDIR=C:\Program Files\PowerShell\7` in its `RemotePowerShellConfig.txt`.

Actual behavior

PS C:\Windows\System32> Enter-PSSession -ComputerName $ServerIP -Credential $Cred -ConfigurationName "PowerShell.7"

Enter-PSSession: Connecting to remote server 192.168.88.223 failed with the following error message : <f:WSManFault xmlns:f="http://schemas.microsoft.com/wbem/wsman/1/wsmanfault" Code="2689860592" Machine="192.168.88.223"><f:Message><f:ProviderFault provider="PowerShell.7" path="C:\Windows\system32\PowerShell\7.6.3\pwrshplugin.dll"></f:ProviderFault></f:Message></f:WSManFault> For more information, see the about_Remote_Troubleshooting Help topic.

The remote connection fails. The installer registers the `PowerShell.7` endpoint with a hardcoded version suffix in the XML path: `C:\Windows\System32\PowerShell\7.6.3\pwrshplugin.dll`. 

Inside the `7.6.3` directory, the `RemotePowerShellConfig.txt` file points to the isolated Microsoft Store folder (`C:\Program Files\WindowsApps\Microsoft.PowerShell_7.6.3.0_x64__8wekyb3d8bbwe`). Because the WinRM system service lacks permissions to access the `WindowsApps` folder, it rejects the connection.

Error details

Connecting to remote server failed with the following error message: 
<f:WSManFault xmlns:f="http://microsoft.com" Code="2689860592" Machine="192.168.88.223"><f:Message><f:ProviderFault provider="PowerShell.7" path="C:\Windows\system32\PowerShell\7.6.3\pwrshplugin.dll"></f:ProviderFault></f:Message></f:WSManFault>

Followed by:
"The WS-Management service cannot process the request. The service is configured to decline remote connection requests for this plugin."

Environment data

Name                           Value
----                           -----
PSVersion                      7.6.3
PSEdition                      Core
GitCommitId                    7.6.3
OS                             Microsoft Windows 10.0.19045
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Visuals

Content of the config files on the server:

cat C:\Windows\System32\PowerShell\7\RemotePowerShellConfig.txt
PSHOMEDIR=C:\Program Files\PowerShell\7
CORECLRDIR=C:\Program Files\PowerShell\7
cat C:\Windows\System32\PowerShell\7.6.3\RemotePowerShellConfig.txt
PSHOMEDIR=C:\Program Files\WindowsApps\Microsoft.PowerShell_7.6.3.0_x64__8wekyb3d8bbwe
CORECLRDIR=C:\Program Files\WindowsApps\Microsoft.PowerShell_7.6.3.0_x64__8wekyb3d8bbwe

The Fix:

Manually editing the ConfigXML parameter under HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\WSMAN\Plugin\PowerShell.7 to change the filename path from ...\PowerShell\7.6.3\... to ...\PowerShell\7\... completely solves the issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs-TriageThe issue is new and needs to be triaged by a work group.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions