Reputation: 31
Enter-PSSession
command works on remote PC with port 5985, but whenever I specify the port 5986 (HTTPS), it shows the following error:
Enter-PSSession : 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.
At line:1 char:1
+ Enter-PSSession -ComputerName localhost -Port 5986
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (localhost:String) [Enter-PSSession], PSRemotingTransportException
+ FullyQualifiedErrorId : CreateRemoteRunspaceFailed
I have tried to enable port 5986 in firewall and even completely disabled the firewall but still can't solve the problem. So, how can I enable port 5986 for PSSession?
Upvotes: 2
Views: 5087
Reputation: 387
I was faced with this problem.
Are you created certificate on server? If not then... Run in PowerShell as Administrator:
New-SelfSignedCertificate -DnsName <your_server_dns_name_or_whatever_you_like> -CertStoreLocation Cert:\LocalMachine\My
and save returned thumbprint. Thumbprint will you need.
Are you configured WinRM on server? If not then... Run cmd.exe as Administrator and run it:
winrm create winrm/config/Listener?Address=*+Transport=HTTPS @{Hostname=”<your_server_dns_name_or_whatever_you_like>”; CertificateThumbprint=”<certificate_thumbprint_from powershell>”}`
Try login to server:
$so = New-PsSessionOption –SkipCACheck -SkipCNCheck
Enter-PSSession -ComputerName <ip_address_or_dns_name_of_server> -Credential <local_admin_username> -UseSSL -SessionOption $so
Also may be you need configure winrm for client. Run cmd.exe as Administrator and run it:
winrm set winrm/config/client @{TrustedHosts="<ip_remote_server>"}
Upvotes: 1