Skip to content

Instantly share code, notes, and snippets.

@ChabaOk
Last active December 23, 2016 10:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ChabaOk/d51f1659021703503b424f9eee44b32b to your computer and use it in GitHub Desktop.
Save ChabaOk/d51f1659021703503b424f9eee44b32b to your computer and use it in GitHub Desktop.
Add winrm trusted host
Start-Service WinRM
$myTrustWinRM = get-Item WSMan:\localhost\Client\TrustedHosts
if($myTrustWinRM.Value.Length -eq 0)
{
$myNewTrust = "192.168.1.113"
Write-Host "new trustedhosts"
}
else
{
$myTargetServerIP = "192.168.1.113"
$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