Skip to content

Instantly share code, notes, and snippets.

Last active December 23, 2016 10:39
What would you like to do?
Add winrm trusted host
Start-Service WinRM
$myTrustWinRM = get-Item WSMan:\localhost\Client\TrustedHosts
if($myTrustWinRM.Value.Length -eq 0)
$myNewTrust = ""
Write-Host "new trustedhosts"
$myTargetServerIP = ""
$myNewTrust = ($myTrustWinRM).Value + ", $myTargetServerIP"
Write-Host "append trustedhosts"
Set-Item WSMan:\localhost\Client\TrustedHosts -Value $myNewTrust
$MyCred = Get-Credential "administrator"
$nanoPSHost = New-PSSession -ComputerName $myNewTrust -Credential $MyCred
Enter-PSSession -Id ($nanoPSHost).id
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment