Created
October 21, 2016 10:18
-
-
Save euyuil/64d89b044721ddb14fafa2e87698b21d to your computer and use it in GitHub Desktop.
WinRM: Enable WinRM and create an HTTPS listener with self-signed certificate.
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
Param ($DnsName) | |
$Cert = New-SelfSignedCertificate -CertStoreLocation Cert:\LocalMachine\My -DnsName $DnsName -Verbose | |
$Password = ConvertTo-SecureString -String $DnsName -Force -AsPlainText -Verbose | |
Export-Certificate -Cert $Cert -FilePath .\$DnsName.cer -Verbose | |
Export-PfxCertificate -Cert $Cert -FilePath .\$DnsName.pfx -Password $Password -Verbose | |
$CertThumbprint = $Cert.Thumbprint | |
Enable-PSRemoting -Force -Verbose | |
Set-Item WSMan:\localhost\Client\TrustedHosts * -Force -Verbose | |
New-Item -Path WSMan:\localhost\Listener -Transport HTTPS -Address * -CertificateThumbPrint $CertThumbprint -Force -Verbose | |
Restart-Service WinRM -Verbose | |
New-NetFirewallRule -DisplayName "Windows Remote Management (HTTPS-In)" -Name "WinRMHTTPSIn" -Profile Any -LocalPort 5986 -Protocol TCP -Verbose |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
thanks :3 3rd_place_medal: