You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在PowerShell中添加TrustedHosts?遇策略需设为‘not configured’错误求解决

搞定PowerShell添加TrustedHosts的策略限制问题

别担心,这个错误是因为系统的组策略限制了TrustedHosts的修改权限,咱们一步步来解决:

第一步:先调整组策略设置

这个错误提示里说的“策略设置为Enabled”,指的是本地(或域)组策略里已经锁定了TrustedHosts的配置,得先把这个限制放开:

  • 按下Win + R,输入gpedit.msc打开本地组策略编辑器。
  • 顺着路径找:计算机配置 > 管理模板 > Windows组件 > Windows远程管理(WinRM) > WinRM服务
  • 找到配置WinRM服务的TrustedHosts列表这个选项,双击打开。
  • 把它改成「未配置」或者「禁用」,点确定保存。
  • 最后跑个命令gpupdate /force,强制刷新组策略让修改生效。

第二步:添加TrustedHosts

策略放开后,就可以正常用PowerShell命令添加了:

  • 加单个主机/IP:Set-Item WSMan:\localhost\Client\TrustedHosts -Value "你的主机名或IP地址"
  • 加多个主机(用逗号隔开):Set-Item WSMan:\localhost\Client\TrustedHosts -Value "主机1,主机2,192.168.1.100"
  • 追加新主机(不覆盖现有列表):Set-Item WSMan:\localhost\Client\TrustedHosts -Value (Get-Item WSMan:\localhost\Client\TrustedHosts).Value + ",新主机名"

第三步:验证是否成功

输入下面的命令就能看到当前的TrustedHosts列表啦:
Get-Item WSMan:\localhost\Client\TrustedHosts

要是你在域环境里,本地组策略可能会被域策略覆盖,这时候就得找域管理员帮忙调整域组策略咯。

内容的提问来源于stack exchange,提问作者Vinay K

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.27 07:05:38