How to add more than one machine to the trusted hosts list using winrm
hosts, powershell, windows, winrm
Solution
I prefer to work with the PSDrive `WSMan:\`.
Get TrustedHosts
Get-Item WSMan:\localhost\Client\TrustedHosts
Set TrustedHosts
provide a single, comma-separated, string of computer names
Set-Item WSMan:\localhost\Client\TrustedHosts -Value 'machineA,machineB'
or (dangerous) a wild-card
Set-Item WSMan:\localhost\Client\TrustedHosts -Value '*'
to append to the list, the `-Concatenate` parameter can be used
Set-Item WSMan:\localhost\Client\TrustedHosts -Value 'machineC' -Concatenate
Problem
To run powershell commands on a machine from a remote machine we have to add the remote machine to the trusted hosts list of the host machine. I am adding machine A to machine B's trusted hosts using the following command : ``` winrm set winrm/config/client ‘@{TrustedHosts="machineA"}’ ``` How to add more machines say machine C, machine D to trusted hosts list of machine B?