要从远程机器在机器上运行 powershell 命令,我们必须将远程机器添加到主机的受信任主机列表中。
我正在使用以下命令将机器 A 添加到机器 B 的受信任主机:
winrm set winrm/config/client ‘@{TrustedHosts="machineA"}’
如何将更多机器如机器C、机器D添加到机器B的可信主机列表中?
最佳答案
我更喜欢使用 PSDrive WSMan:\
。
获取 TrustedHosts
Get-Item WSMan:\localhost\Client\TrustedHosts
设置 TrustedHosts
提供一个逗号分隔的计算机名称字符串
Set-Item WSMan:\localhost\Client\TrustedHosts -Value 'machineA,machineB'
或(危险的)通配符
Set-Item WSMan:\localhost\Client\TrustedHosts -Value '*'
要追加到列表中,可以使用-Concatenate
参数
Set-Item WSMan:\localhost\Client\TrustedHosts -Value 'machineC' -Concatenate
关于windows - 如何使用 winrm 将多台机器添加到受信任的主机列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21548566/