How to add servers to TrustedHosts list via PowerShell and command Prompt

In Windows environments using Windows Remote Management (WinRM) can help discover servers using the WinRM protocol. To run PowerShell commands on a device from a remote computer, we have to add the remote machine to the trusted hosts list of the host machine.

– Ensure the computers (servers) are added in the TrustedHosts. Instead of adding an individual host, use the asterisk (a wild-card) to add all subsequent hosts. Note, this is not recommended.

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

– Or you can add an individual computer by using the command below

Set-Item WSMan:Localhost\client\trustedhosts TechDArchive

You can add multiple servers using the command below, provide a single, comma-separated, string of computer names

Set-Item WSMan:\localhost\Client\TrustedHosts -Value 'Server1,TechDArchive'

– Also, you can add all domain computers to the TrustedHosts list as shown below

Set-Item WSMan:\localhost\Client\TrustedHosts *

– To do this via the command-line, run the following command below

winrm set winrm/config/client @{TrustedHosts="RemoteComputerName"}

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