Sunday, November 27, 2016

The WS-Management service cannot process the request. Cannot find the Microsoft.PowerShell session configuration in the WSMan: drive on the...

After updating to Ps 4.0, I found some windows hosts are encountering the following errors when I run Invoke-Command to check the powershell version. See Fig-1.

Connecting to remote server X.X.X.X failed with the following error message : The WS-Management service cannot process the request. Cannot find the Microsoft.PowerShell session configuration in the WSMan: drive on the X.X.X.X computer.

Figure-1: Failed to connect to remote host
After a few googling, I found that the problem is Default Powershell Configuration Session, Microsoft.powershell has been unregistered and there is only Microsoft.powershell.workflow registered. Check it by the following Ps command in elevated administrative mode. See Fig-2.
Get-PSSessionConfiguration

(We need Powershell remote endpoints when connecting to remote computers by New-PSSession or Invoke-Command to make a successful remote powershell session. The standard (default) one is Microsoft.powershell. We can also restrict users permissions, specific cmdlets/functions that are allowed to users to run and  by creating new custom endpoints or modifying current endpoints, that is called Constrained Endpoints. You can check the default endpoint configuration by this command.
 Get-PSSessionConfiguration -Name microsoft.powershell | Select *
You can learn more about Powershell Endpoints & how to setup constrained endpoints here>>
https://blogs.technet.microsoft.com/heyscriptingguy/2014/03/31/introduction-to-powershell-endpoints/
http://blog.netwrix.com/2015/02/11/secure-powershell-remoting-using-constrained-endpoints/
)

Then we need to re-register the default endpoint back. You can enter 'A' for all confirmations. This will only register the selected endpoint & restart the WinRM service. See Fig-2j.
Register-PSSessionConfiguration -Name Microsoft.powershell

Then you can check it if it successfully registered. See Fig-2.
Get-PSSessionConfiguration

Fig-2: Check & re-register the endpoint
Now, re-check you are able to connect the host. See Fig-3.
Fig-3: Recheck the connection

4 comments:

  1. Good article
    Thanks for you help :)

    ReplyDelete
  2. Worked like a charm for me. Thank you.

    ReplyDelete
  3. Nice Blog, Best best microsoft office deals for Mac Home and Business edition is a powerful suite which fulfils the productivity applications, written for Mac OS X.

    ReplyDelete

Note: Only a member of this blog may post a comment.