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

前端 未结 4 1879
甜味超标
甜味超标 2020-12-02 05:33

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

4条回答
  •  广开言路
    2020-12-02 05:51

    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
    

提交回复
热议问题