# Generates a self signed TLS certificate (you can also use your certificate service)
New-SelfSignedCertificate -Subject 'CN=admin.com' -TextExtension '2.5.29.37={text}1.3.6.1.5.5.7.3.1'
# Creates a new HTTPS listener that uses the certificate created before
winrm create winrm/config/Listener?Address=*+Transport=HTTPS '@{Hostname="admin.com"; CertificateThumbprint="[证书指纹]"}'
# Opening port 5986 on the internal firewall
$FirewallParam = @{
DisplayName = 'WinRM HTTPS'
Direction = 'Inbound'
LocalPort = 5986
Protocol = 'TCP'
Action = 'Allow'
Program = 'System'
}
New-NetFirewallRule @FirewallParam