Skip to content

Instantly share code, notes, and snippets.

@giseongeom
Last active June 1, 2018 09:59
Show Gist options
  • Select an option

  • Save giseongeom/9aa7e7b419a36cbb04fa03d8861241a9 to your computer and use it in GitHub Desktop.

Select an option

Save giseongeom/9aa7e7b419a36cbb04fa03d8861241a9 to your computer and use it in GitHub Desktop.
Enable WinRM HTTPS Listener on Windows Server 2016
#Requires -version 5
#Requires -RunAsAdministrator
# Add firewall rule
New-NetFirewallRule -DisplayName WINRM-HTTPS-In-TCP `
-Name WINRM-HTTPS-In-TCP -Enabled True -Protocol TCP `
-Profile Any -Direction Inbound -RemoteAddress Any `
-LocalPort 5986
# Cert
$computer = Get-ComputerInfo
$newselfcert = New-SelfSignedCertificate `
-DnsName $computer.CsDNSHostName `
-CertStoreLocation Cert:\LocalMachine\My
# Enable HTTPS Listener
New-Item -Path WSMan:\Localhost\Listener `
-Transport HTTPS -Address * `
-CertificateThumbprint $newselfcert.Thumbprint -Force
# (Optional) Disable LocalAccountTokenFilterPolicy
# Use with care
New-ItemProperty -Name LocalAccountTokenFilterPolicy `
-Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System `
-PropertyType DWord -Value 1 -Force
# Check Configuration
& WinRM e winrm/config/listener
@giseongeom
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment