Wednesday, April 23, 2014

PowerShell - Correctly setting TrustedHosts

Hi guys

PowerShell has become such a valuable tool for administrators, that I myself am getting way too lazy to even think about opening RDP sessions to my servers. An extremely important function (obviously) is to be able to execute commands on remote machines; however you might run into trouble (especially when specifying the remote machine by IP) with default authentication issues:

Enter-PSSession : Connecting to remote server failed with the following error message : The WinRM client cannot process the request. Default authentication may be used with an IP address under the following conditions: the transport is HTTPS or the destination is in the TrustedHosts list, and explicit credentials are provided. Use winrm.cmd to configure TrustedHosts. Note that computers in the TrustedHosts list might not be authenticated. For more information on how to se
t TrustedHosts run the following command: winrm help config. For more information, see the about_Remote_Troubleshooting Help topic.

To quickly configure TrustedHosts on your client, simply run the following command on the client machine (through a console with elevated privileges):

Set-Item wsman:\localhost\Client\TrustedHosts <yourservernameorip> -Concatenate -Force
Bob's your uncle!
Now go ahead and run your beloved 'Enter-PSSession' command again!
Be happy, life is good :)

No comments:

Post a Comment