Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

powershell remoting Win2008R2 "The WSMan service could not launch a host process to process the given request"

I've recently upgraded a number of servers from 2003 to 2008R2. Since the upgrade I've started to see the following error:

[servername] Connecting to remote server failed with the following error message : The WSMan service could not launch a host process to process the given request. Make sure the WSMan provider host server and proxy are properly registered. For more information, see the about_Remote_Troubleshooting Help topic.

The error is seemingly random. The script will work and then fail. The command to create the session is in a loop (create session, remove session) and is called numerous times as part of a set of deployment scripts. When the script fails, it fails at different points.

I've checked the event log on the local workstation (win7) destination server (win2008R2) but there are no errors that I can see.

This is the lines that randomly fails:

$session = New-PSSession -ComputerName $serverName -Credential $credential

I did not see this issue on Win2003. The scripts have not changed. I'm assuming the problem is on the destination server but cannot find any errors or logs to look at. It will work once and then fail so my deployment scripts will sometimes succeed and then fail at different points.

Any guidance on tracking down this problem would be much appreciated.

like image 363
richard wadsworth Avatar asked Jan 05 '12 18:01

richard wadsworth


2 Answers

You can get this error when trying to connect to localhost with an account that's not an administrator.

It used to be possible to use accounts that weren't an administrator, but a Windows Update in January 2019 disabled the functionality for security reasons. From the patch notes:

By default, PowerShell remoting only works with administrator accounts, but can be configured to work with non-administrator accounts. Starting with this release, you cannot configure PowerShell remote endpoints to work with non-administrator accounts. When attempting to use a non-administrator account, the following error will appear:“New-PSSession: [computerName] Connecting to remote server localhost failed with the following error message: The WSMan service could not launch a host process to process the given request. Make sure the WSMan provider host server and proxy are properly registered. For more information, see the about_Remote_Troubleshooting Help topic.”

like image 53
Will Avatar answered Nov 05 '22 06:11

Will


You need to be setting the WSMan TrustedHosts. If you want, you can set it to everything using wildcards (*).

You can do it via PowerShell: Set-Item WSMan:\localhost\Client\TrustedHosts -Value *.

Keep in mind that you also need to enable the Windows Remote service. Use the native winrm qc command for this. Enable-PSRemoting -Force might do it as well.

You can also use the PSExec Tools from Sysinternals. Keep in mind that these tools will likely be blocked by your EndPoint Security, so don't forget to white list it.

Is there a specific reason you migrate your old OSes to a newer, but still EOL OS? You can do a lot via PowerShell in 2008R2, but it's still pretty limited. IMO, Using PowerShell is best starting from 2012R2 and onwards.

like image 1
IT M Avatar answered Nov 05 '22 06:11

IT M