Last active
December 23, 2016 10:39
-
-
Save ChabaOk/d51f1659021703503b424f9eee44b32b to your computer and use it in GitHub Desktop.
Add winrm trusted host
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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