Created
December 21, 2016 15:36
-
-
Save bobalob/6a406b93718eea8f04936179b2b3623f to your computer and use it in GitHub Desktop.
This file contains hidden or 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
$RemoteHostName = $ENV:ComputerName | |
$ComputerName = $ENV:ComputerName | |
Write-Host "Setup WinRM for $RemoteHostName" | |
$Cert = New-SelfSignedCertificate -DnsName $RemoteHostName, $ComputerName ` | |
-CertStoreLocation "cert:\LocalMachine\My" | |
$Cert | Out-String | |
$Thumbprint = $Cert.Thumbprint | |
Write-Host "Enable HTTPS in WinRM" | |
$WinRmHttps = "@{Hostname=`"$RemoteHostName`"; CertificateThumbprint=`"$Thumbprint`"}" | |
winrm create winrm/config/Listener?Address=*+Transport=HTTPS $WinRmHttps | |
Write-Host "Set Basic Auth in WinRM" | |
$WinRmBasic = "@{Basic=`"true`"}" | |
winrm set winrm/config/service/Auth $WinRmBasic | |
Write-Host "Open Firewall Port" | |
netsh advfirewall firewall add rule name="Windows Remote Management (HTTPS-In)" dir=in action=allow protocol=TCP localport=$WinRmPort |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment