Forked from gregjhogan/winrm-https-self-signed-cert.ps1
Created
November 5, 2024 01:58
-
-
Save thinkst-cs/9b743869e1d022f63c2b0314ad492d79 to your computer and use it in GitHub Desktop.
Configure WinRM HTTPS w/ self-signed certificate
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
| # configure | |
| $cert = New-SelfSignedCertificate -CertstoreLocation Cert:\LocalMachine\My -DnsName $env:COMPUTERNAME | |
| Enable-PSRemoting -SkipNetworkProfileCheck -Force | |
| New-Item -Path WSMan:\LocalHost\Listener -Transport HTTPS -Address * -CertificateThumbPrint $cert.Thumbprint –Force | |
| New-NetFirewallRule -DisplayName "Windows Remote Management (HTTPS-In)" -Name "Windows Remote Management (HTTPS-In)" -Profile Any -LocalPort 5986 -Protocol TCP | |
| # connect | |
| Enter-PSSession -ComputerName {X.X.X.X} -Credential (Get-Credential) -SessionOption (New-PsSessionOption -SkipCACheck -SkipCNCheck) -UseSSL |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment