如何使用 winrm 将多台机器添加到受信任主机列表 [英] How to add more than one machine to the trusted hosts list using winrm

查看:98
本文介绍了如何使用 winrm 将多台机器添加到受信任主机列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

要从远程机器在机器上运行 powershell 命令,我们必须将远程机器添加到主机的受信任主机列表中.

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.

我正在使用以下命令将机器 A 添加到机器 B 的受信任主机:

I am adding machine A to machine B's trusted hosts using the following command :

winrm set winrm/config/client ‘@{TrustedHosts="machineA"}’

如何将机器 C、机器 D 等机器添加到机器 B 的可信主机列表中?

How to add more machines say machine C, machine D to trusted hosts list of machine B?

推荐答案

我更喜欢使用 PSDrive WSMan:\.

I prefer to work with the PSDrive WSMan:\.

获取 TrustedHosts

Get-Item WSMan:\localhost\Client\TrustedHosts

设置 TrustedHosts

提供单个以逗号分隔的计算机名称字符串

provide a single, comma-separated, string of computer names

Set-Item WSMan:\localhost\Client\TrustedHosts -Value 'machineA,machineB'

或(危险的)通配符

Set-Item WSMan:\localhost\Client\TrustedHosts -Value '*'

要附加到列表中,可以使用-Concatenate 参数

to append to the list, the -Concatenate parameter can be used

Set-Item WSMan:\localhost\Client\TrustedHosts -Value 'machineC' -Concatenate

这篇关于如何使用 winrm 将多台机器添加到受信任主机列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆