How to add trusted host for the WinRM client

When you want to remotely manage a list of computer through WinRM (Windows Remote Management), you have to add computers to the TrustedHosts list. Otherwise, you may most likely encounter errors when communicating between the two sides. Using PowerShell, you can see what the current records are in the TrustedHosts file but also how to add new records depending on your scenario.

Below are the steps to add a server to the TrsutedHosts for WinRM client.

Set-Item WSMan:localhost\client\trustedhosts -value *

Note: You can add individual servers to the TrustHost via the following methods below.

Set-Item WSMan:localhost\client\trustedhosts -value ServerDC 

In this way, you can add multiple servers to the TrustedHosts for WinRM.

Set-Item WSMan:\localhost\Client\TrustedHosts -Value 'ServerDC,AnsibleClient'

To make this command run in an unattended mode (silently) without prompting you to acknowledge the security configuration, add the -Force to the command as shown below.

Set-Item WSMan:localhost\client\trustedhosts -value ServerDC -Force

You can also read the trusted host list with PowerShell, run the command below.

Get-Item WSMan:\localhost\Client\TrustedHosts

To add all domain computers to the TrustedHosts list, use the command as follow, Set-Item WSMan:\localhost\Client\TrustedHosts *

Set-Item WSMan:\localhost\Client\TrustedHosts *.techdirect.local

I hope you find these tips useful 😉

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s