In this blog post, I will show you how to add a Trusted Host to a Windows Server or Windows 10 machine using PowerShell.
We add Trusted hosts to a Windows machine using the PowerShell get-item command.
The reason we need to add trusted hosts is to allow us to connect to a Windows machine using WinRM.
Check Hosts
First, let check our trusted host list using the following line.
Get-Item WSMan:\localhost\Client\TrustedHosts
Note: If you have existing hosts in the list skip to the second section of this post and add a host to an existing list.
![](https://ntweekly-3e2e1f4957bdf35452c0-endpoint.azureedge.net/blobntweekly18036ad1fb/wp-content/uploads/2020/06/061220_0115_AddaTrusted1.png)
Add Host to a new computer
If your list is empty run the following command with the IP or hostname of the machine you are adding.
Set-Item WSMan:\localhost\Client\TrustedHosts -Value 192.168.1.100
![](https://ntweekly-3e2e1f4957bdf35452c0-endpoint.azureedge.net/blobntweekly18036ad1fb/wp-content/uploads/2020/06/061220_0115_AddaTrusted2.png)
Add Trusted Host to Existing list
To add a host to an existing list, first, export the list to a variable called List.
$List = (Get-Item WSMan:\localhost\Client\TrustedHosts).value
Run the following command with the List variable and the new host IP or name, in my case the new host is 172.16.0.4.
Set-Item WSMan:\localhost\Client\TrustedHosts -Value "$List, 172.16.0.4"
![](https://ntweekly-3e2e1f4957bdf35452c0-endpoint.azureedge.net/blobntweekly18036ad1fb/wp-content/uploads/2020/06/061220_0115_AddaTrusted3.png)
Check Trusted Hosts
To check the hosts in the list run the following command.
Get-item WSMan:\localhost\client\TrustedHosts
Thanks!! 🙂