(PowerShell)檢查/設定TrustedHosts

取得目前TrustedHosts名單

1
Get-Item WSMan:\localhost\Client\TrustedHosts

設定TrustedHosts

1
2
3
4
5
6
7
8
# 設定特定的IP
winrm set winrm/config/client '@{TrustedHosts="xxx.xxx.xxx.xxx,yyy.yyy.yyy.yyy"}'

# 設定allow all *
Set-Item WSMan:\localhost\Client\TrustedHosts -Value "*" -Force

#加入TrustedHosts (Concatenate是append,若沒加Concatenate,會一直覆蓋)
Set-Item WSMan:\localhost\Client\TrustedHosts -Value "zzz.zzz.zzz" -Concatenate

重啟WinRM Service

1
Restart-Service WinRM