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

前端 未结 4 1871
甜味超标
甜味超标 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 06:01

    The suggested answer by Loïc MICHEL blindly writes a new value to the TrustedHosts entry.
    I believe, a better way would be to first query TrustedHosts.
    As Jeffery Hicks posted in 2010, first query the TrustedHosts entry:

    PS C:\> $current=(get-item WSMan:\localhost\Client\TrustedHosts).value
    PS C:\> $current+=",testdsk23,alpha123"
    PS C:\> set-item WSMan:\localhost\Client\TrustedHosts –value $current
    

提交回复
热议问题