Add a Trusted Host to a Windows 10 Machine PowerShell

 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 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.

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

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"

Check Trusted Hosts

To check the hosts in the list run the following command.

Get-item WSMan:\localhost\client\TrustedHosts

Processing…
Success! You're on the list.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.