How to Configure WinRM over HTTPS (Port 5986)

Satyam

Last Update 7 bulan yang lalu

By default, WinRM over HTTP (port 5985) uses Kerberos to encrypt communications post-authentication, but the initial connection lacks TLS-based protection.
Switching to WinRM over HTTPS (port 5986) adds both encryption and server identity validation via certificates, offering enhanced security.

Prerequisites Check

WinRM Service:
Run the following command to confirm WinRM is installed and to view the current authentication settings:

winrm get winrm/config


Certificate Requirements:


  • A valid Server Authentication certificate must be present in the Local Computer → Personal → Certificates store.

  • It must:

    • Have a matching Common Name (CN) or Subject Alt Name (SAN) for the host.

    • Be current (not expired or revoked).

 Step 1: Choose Your Certificate Type

You can configure WinRM over HTTPS using either:


  • Option 1: A CA-signed certificate (recommended for production)

  • Option 2: A self-signed certificate (for testing or internal lab environments)

Option 1 – Configure WinRM using a CA-Signed Certificate (Recommended)
If your organization uses a Certificate Authority (CA), follow this workflow.

Step 1.1: Obtain and Install a Certificate

If you don’t have one, request it from your corporate CA or Microsoft Certificate Server.
After installation, list certificates and copy the thumbprint:

Get-ChildItem Cert:\LocalMachine\My 

Step 1.2: Create the HTTPS Listener

You can do this in one of two ways:


Option A: Quick Configuration

winrm quickconfig -transport:https 

This command:


  • Starts the WinRM service

  • Sets it to auto-start

  • Creates an HTTPS listener

  • Adds a firewall rule for port 5986


Option B: Manual Configuration

# Replace hostname.domain.com and THUMBPRINT with actual values

winrm create winrm/config/Listener?Address=*+Transport=HTTPS "@{Hostname='hostname.domain.com'; CertificateThumbprint='THUMBPRINT'}"


Step 1.3: Add Firewall Rule (if needed)
netsh advfirewall firewall add rule name="WinRM HTTPS" dir=in action=allow protocol=TCP localport=5986 


Step 1.4: Validate the Configuration
winrm enumerate winrm/config/listener 


Ensure Transport=HTTPS and Port=5986 are displayed.


Then test connectivity:

$cred = Get-Credential
Enter-PSSession -ComputerName hostname.domain.com -Port 5986 -UseSSL -Credential $cred


Option 2 – Configure WinRM using a Self-Signed Certificate (For Testing / Lab Environments)

If you don’t have a CA-signed certificate, you can create and use a self-signed certificate.

Step 2.1: Stop the WinRM Service
Stop-Service WinRM -Force -ErrorAction SilentlyContinue 


Step 2.2: Configure Basic WinRM Settings
winrm quickconfig -q winrm set winrm/config/service '@{AllowUnencrypted="false"}' winrm set winrm/config/service/auth '@{Basic="true"}'

winrm set winrm/config/service/auth '@{Certificate="true"}'

winrm set winrm/config/client/auth '@{Basic="true"}'

winrm set winrm/config/client/auth '@{Certificate="true"}'


Step 2.3: Create a Self-Signed Certificate
$hostname = $env:COMPUTERNAME

$cert = New-SelfSignedCertificate -DnsName $hostname -CertStoreLocation Cert:\LocalMachine\My -KeyUsage DigitalSignature,KeyEncipherment -KeyAlgorithm RSA -KeyLength 2048

 $thumbprint = $cert.Thumbprint

Step 2.4: Remove Any Existing HTTPS Listeners
Get-ChildItem WSMan:\localhost\Listener | Where-Object {$_.Keys -contains "Transport=HTTPS"} | Remove-Item -Recurse -Force 


Step 2.5: Create a New HTTPS Listener Using the Self-Signed Certificate
winrm create winrm/config/Listener?Address=*+Transport=HTTPS "@{Hostname=`"$hostname`";CertificateThumbprint=`"$thumbprint`";Port=`"5986`"}" 


Step 2.6: Add Firewall Rule (if required)
netsh advfirewall firewall add rule name="WinRM HTTPS" dir=in action=allow protocol=TCP localport=5986 


Step 2.7: Start and Enable WinRM Service
Start-Service WinRM Set-Service WinRM -StartupType Automatic 


Step 2.8: Validate Configuration


List Listeners:

winrm enumerate winrm/config/listene


Test Local Connection:

Test-WsMan -ComputerName $env:COMPUTERNAME -Port 5986 -UseSSL 


Test Remote Connection (Skip CA Validation):

$cred = Get-Credential Enter-PSSession -ComputerName $hostname -Port 5986 -UseSSL -Credential $cred -SessionOption (New-PSSessionOption -SkipCACheck) 

⚠️ Note:
Self-signed certificates are not trusted by default.
For remote connections, either:

  • Use -SkipCACheck, or

  • Import the self-signed certificate into the Trusted Root Certification Authorities store on the client system.

References

Was this article helpful?

0 out of 0 liked this article

Still need help? Message Us