WINRM Enter-Pssession not working on new machine

winrm

I am trying to enable win rm in mixed domain mode on a new machine.

From another work station, I can connect with the following command:

Enter-PSSession -ComputerName 89.251.114.100 -Credential $mycred

I have ran Enable-PSremoting on the new machine but when I execute the following command, I get:


Enter-PSSession : Connecting to remote server failed with the following error message : Access is denied. For more info
rmation, see the about_Remote_Troubleshooting Help topic.
At C:\Users\Dev1\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1:93 char:17
+ Enter-PSSession <<<< -ComputerName 89.251.114.100 -Credential $mycred
+ CategoryInfo : InvalidArgument: (00.000.000.000:String) [Enter-PSSession], PSRemotingTransportException
+ FullyQualifiedErrorId : CreateRemoteRunspaceFailed

It is the InvalidArgument that strikes me as odd.

Interestingly, I can execute remote commands with:

powershell.exe -ExecutionPolicy unrestricted C:\root\deploy.ps1 -inputformat none

Best Answer

Does the user account in your PSCredential object belong to the administrators group of the target machine?

Did you run winrm quickconfig on the new machine in an elevated command prompt? It should start the winrm service and create a winrm listener on tcp port 5985 with the corresponding firewall exception. You can then try to run winrs -r:http://<targetmachine>:5985 -u:<targetmachine>\<administrator account> "dir c:\" and see if it outputs the contents of C:. This shows you that winrm is working correctly.

After that try running Enable-PSRemoting on the target machine again (again in an elevated Powershell prompt).