A while ago I came across an interesting problem I’d like to share with you. Running Enter-PSSession command from one particular terminal server always failed with following error message:
To make the matters worse, that terminal server was our management server, that is the single server that is used to manage a few thousand workstations. I was pretty sure that the remote host client2 was reachable, and configured correctly, because I was able to connect to it from other servers using the same command. But still this single terminal server refused to connect to the client. I tried everything I could come up with or find on the Internet, but to no avail. I was determined to fix this, so I waited for the night hours to have management server free of users and I sniffed the network communication while running the Enter-PSSession repeatedly. In the network sniff I saw a very strange DNS queries for some host “proxy-server” which did not exist in our network.
Finally I got some lead and I started to Google for description of how PowerShell uses proxy server configuration. I found out that it is using proxy setting configured for the “SYSTEM” account. I checked the proxy configuration for that account and I found out that my colleague has accidentally configured a non existing proxy server on this management server.
I changed the settings back to “none” proxy server using the netsh native command.
Running the Enter-PSSession command again I immediately saw that the server was able to reach “client2” and that the communication was successfully started:
In the screenshot you can see a Kerberos ticket request for client2, followed by DNS query for client2 and finally HTTP communication for the Enter-PSSession command.
This also meant that I was finally able to enter a PSSession and the problem was fixed.