In my previous post: Centralize Powershell Script (Modules) Repository, it describes on how to create a custom module and load it on any server. And like the title of this post indicated when you try to connect to a remote server using Powershell remoting, you’ll notice that the custom module is missing ( More information about Powershell Remoting ). This is because it’s doing a double-hop, First hop is to connect to server (using Enter-PSSession or New-PSSession), next hop is to access the shared folder containing the custom module.
To solve this issue we need to Enable the Credential Service Security Provider (CredSSP) both on remote and host server.
#1 On the server wherein the powershell console instance is started you need to enable the client role.
#2 On the server wherein you want to connect remotely you need to enable server role.
#3 On the server wherein the powershell script is hosted you also need to enable the server role.
Run the following scripts (Run as Administrator):
Script for # 1:
Enable-WSManCredSSP -role Client -DelegateComputer-force
Script for # 2:
Enable-WSManCredSSP -role Server -force
Script for # 3:
Enable-WSManCredSSP -role Server -force
Powershell remoting with CredSSP:
To connect either by Enter-PSSession or New-PSSession you need to supply extra argument:
$session = New-PSSession -ComputerName-Authentication CredSSP -Credential Get-Credential
Since i used Get-Credential it would prompt for credential:
Update:
If it still doesn’t work, try restarting the Windows Remote Management (WS-Management) service.
In Run Type, services.msc
In the Name look for: Windows Remote Management (WS-Management), right click Restart.