PowerShell / WindowsCompatibility

Module that allows Windows PowerShell Modules to be used from PSCore6
Other
137 stars 33 forks source link

The client cannot connect to the destination specified in the request (localhost) #73

Open rjmholt opened 5 years ago

rjmholt commented 5 years ago

From https://github.com/aspnet/AspNetCore.Docs/issues/12332.

Full description of the problem from @scottluskcis:

The first command succeeds but the Import-WinModule command fails with this error

PS C:\Users\MyUser> Import-WinModule Microsoft.PowerShell.LocalAccounts
New-PSSession : [localhost] Connecting to remote server localhost failed with th
e following error message : The client cannot connect to the destination specifi
ed in the request. Verify that the service on the destination is running and is
accepting requests. Consult the logs and documentation for the WS-Management ser
vice running on the destination, most commonly IIS or WinRM. If the destination
is the WinRM service, run the following command on the destination to analyze an
d configure the WinRM service: "winrm quickconfig". For more information, see th
e about_Remote_Troubleshooting Help topic.
At C:\Users\MyUser\Documents\PowerShell\Modules\WindowsCompatibility\1.0.0\Wi
ndowsCompatibility.psm1:232 char:20
+         $session = New-PSSession @newPSSessionParameters | Select-Obj ...
+                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : OpenError: (System.Management.A\u2026tion.RemoteRunspa
ce:RemoteRunspace) [New-PSSession], PSRemotingTransportException
+ FullyQualifiedErrorId : CannotConnect,PSSessionOpenFailed

I am trying this on Windows 8.1 Enterprise for example. Are there any additional steps that need to be mentioned in the NOTE?

copdips commented 5 years ago

I managed to install it by Install-Module WindowsCompatibility -Scope CurrentUser without any issue.

But afterward, even for a simple Set-Location command, I got exactly the same bug above.

My Windows 10 version is very recently moved to the insider slow ring one : Microsoft Windows [version 10.0.18362.175]

My pwsh version is 6.2.1

chucklu commented 4 years ago

encounter the same problem on 7.0.1, already installed WindowsCompatibility

Import-WinModule Microsoft.PowerShell.Management New-PSSession: C:\Users\clu\Documents\PowerShell\Modules\WindowsCompatibility\1.0.0\WindowsCompatibility.psm1:232 Line | 232 | $session = New-PSSession @newPSSessionParameters | Select-Obj … | ~~~~~~~~~ | [localhost] Connecting to remote server localhost failed with the following error message : The client | cannot connect to the destination specified in the request. Verify that the service on the destination | is running and is accepting requests. Consult the logs and documentation for the WS-Management service | running on the destination, most commonly IIS or WinRM. If the destination is the WinRM service, run | the following command on the destination to analyze and configure the WinRM service: "winrm | quickconfig". For more information, see the about_Remote_Troubleshooting Help topic.

Find-Module WindowsCompatibility

Version Name Repository Description


1.0.0 WindowsCompatibility PSGallery This module provides compatibility utili…

chucklu commented 4 years ago

@rjmholt https://docs.microsoft.com/en-us/windows/win32/winrm/installation-and-configuration-for-windows-remote-management

Run command Winrm quickconfig to enable Windows Remote Management first, then import module will work.

rjmholt commented 4 years ago

In PowerShell 7, you should no longer need the WindowsCompatibility module. Instead try Import-Module -UseWindowsPowerShell <module>