Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save mikebranstein/231f2460e09aa5d53d4df8fd866a3ba0 to your computer and use it in GitHub Desktop.
Save mikebranstein/231f2460e09aa5d53d4df8fd866a3ba0 to your computer and use it in GitHub Desktop.
Add multiple devices to the Trusted Hosts file.
$trustedHosts = Get-Item WSMan:\localhost\Client\TrustedHosts
if ($trustedHosts.Value -eq "") {
Set-Item WSMan:\localhost\Client\TrustedHosts -Value $ipAddress -Force
}
elseif (-not $trustedHosts.Value.Contains($ipAddress)) {
Set-Item WSMan:\localhost\Client\TrustedHosts -Value "$($trustedHosts.Value),$($ipAddress)" -Force
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment