Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add more than one machine to the trusted hosts list using winrm

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?

like image 209
cmm user Avatar asked Feb 04 '14 09:02

cmm user


People also ask

How do I add a computer to my trusted host list?

To add a computer to the TrustedHosts list of a remote computer, use the Connect-WSMan cmdlet to add a node for the remote computer to the WSMan: drive on the local computer. Then use a Set-Item command to add the computer. For more information about the Connect-WSMan cmdlet, see Connect-WSMan.

What are trusted hosts in WinRM?

Windows by default has an empty TrustedHosts list, a list that contains those remote computers (hosts) that you can remotely manage from a client without authentication. In Windows environments using Windows Remote Management (WinRM) can help discover servers using the WinRM protocol.

How do you check trusted hosts list in PowerShell?

How can I find out if any trusted hosts are configured on my local computer? Use the Get-Item cmdlet and view the trusted hosts from the WSMan drive, as shown here.


2 Answers

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 
like image 136
hdev Avatar answered Sep 21 '22 08:09

hdev


winrm set winrm/config/client '@{TrustedHosts="machineA,machineB"}' 
like image 35
Loïc MICHEL Avatar answered Sep 18 '22 08:09

Loïc MICHEL