How to configure WinRM for HTTPS manually
May 21, 2016 |
In this post we will see how you can configureWinRM (Windows Remote Management) service to work with HTTPS manually.
Configuring for HTTPS involves following steps.
- Check whether WinRM service is running
- Create HTTPS listener
- Add firewall exception
- Validate HTTPS listener
- Verify you can connect to the machine via HTTPS
For the demo purposes I have built a new VM using AzureDevTestLab. We will perform the above steps in this VM and enable it for HTTPS communication.
Check whether WinRM service is running
WinRM is installed by default in all supported Windows machines. Ensure that service is inrunning
state inservices
.
Create HTTPS listener
By default when you runwinrm quickconfig
command WinRM is only configured for HTTP (port 5985). You can check already registered listeners by running following command.
WinRM e winrm/config/listener
You will see output like below.
To enable HTTPS for WinRM, you need to open port 5986 and add HTTPS listener in the VM.
Before we start doing that, we will first need to create a self-signed certificate and get its thumbprint. To create a self signed certificate we can use eithermakecert
command or aNew-SelfSignedCertificate
powershell commandlet. I am using powershell commandlet here. Open your powershell window inAdminstrator
mode and run the below command.
New-SelfSignedCertificate-DnsName"<YOUR_DNS_NAME>"-CertStoreLocationCert:\LocalMachine\My
This command will create a new self signed certificate and output the certificate thumbprint.
DNS name used in the above command is your machine hostname and for Aure portal VM’s you can get it from the portal from VM properties.
Copy the thumbprint to clipboard and run the following command. This command will register the HTTPS listener in WinRM
winrmcreatewinrm/config/Listener?Address=*+Transport=HTTPS'@{Hostname="<YOUR_DNS_NAME>"; CertificateThumbprint="<COPIED_CERTIFICATE_THUMBPRINT>"}'
You will see output as below.
Add firewall exception
Via Firewall applet from Control Panel
- Open
Windows Firewall
from Control Panel - Go to
Inbound Rules
then clickNew Rule
- This will open the wizard
- Select Port and then TCP
- Enter port as
5986
- In the next screens select
Allow the connection
- In the profile page check all the checkboxes.
- Finally give a name to the rule.
Via command
You can also do the same operation and add firwall exception for port5986
by running the following command in powershell console asAdministrator
.
# Add a new firewall ruleport=5986netshadvfirewallfirewalladdrulename="Windows Remote Management (HTTPS-In)"dir=inaction=allowprotocol=TCPlocalport=$port
Validate HTTPS listener
You can verify listener you added by running the same command you used above -WinRM e winrm/config/listener
. This will show the new HTTP listener now along with previous HTTPS listener.
Verify you can connect to the machine via HTTPS
We have done with your WinRM configuration and now we need to verify we can connect to this VM using HTTPS.
Run the following commands in powershell window asAdministrator
$hostName="<DNS_NAME>"# example: "mywindowsvm.westus.cloudapp.azure.com"$winrmPort="5986"# Get the credentials of the machine$cred=Get-Credential# Connect to the machine$soptions=New-PSSessionOption-SkipCACheckEnter-PSSession-ComputerName$hostName-Port$winrmPort-Credential$cred-SessionOption$soptions-UseSSL
On entering the last command, you will be logged in to remote machine’s powershell session. As you can see in the screenshot below, you are connected and you can get the items from the remote virtual machine.
That is it then. You can read these other great blog posts on WinRM, AzureDevTestLab and DevOps.
- Deploy new VM in an existing AzureDevTestLab using VSTS
- Copy custom images (VHD) between AzureDevTestLabs
- Configure WinRm with ARM template using PowerShell artifact
- Perfecting Continuous Delivery of NuGet packages for Azure Artifacts
- Azure Pipelines - Git checkout step fails with cannot lock ref error
- View branch policies of your Azure DevOps repository using Azure CLI
- How I built a dashboard in Azure Portal to track Gitflow feature branches
- Installing ASP.NET Core Site Extension for Azure App Service Using ARM template

Utkarsh Shigihalli
Utkarsh is passionate about software development and has experience in the areas of Azure, Azure DevOps, C# and TypeScript. Over the years he has worked as an architect, independent consultant and manager in many countries including India, United States, Netherlands and United Kingdom. He is a Microsoft MVP and has developed numerous extensions for Visual Studio, Visual Studio Code and Azure DevOps.
Do you like our posts? Subscribe to our newsletter!
- acr
- aks
- arm
- agile
- appveyor
- artifacts
- azure
- azure container registry
- azure devops
- azure hybrid benefit
- azure key vault
- azure kubernetes service
- azure oms
- azure pipelines
- azure static webapps
- azureappservice
- azureautomation
- azuredevtestlabs
- boards
- bug2mail
- build
- buildpipeline
- cli
- chatops
- chef
- chrome
- cloud adoption framework
- conftest
- continuous delivery
- continuousmonitoring
- dependency visualizer
- devops
- devops book
- devsecops
- exception
- extensions
- git
- githooks
- github
- governance
- helm
- iac
- jekyll
- keyvault
- kubernetes
- licensing
- machine groups
- msbuild
- netlify
- oms
- perf
- personal
- pester
- pipelines
- powershell
- releasegates
- releasemanagement
- servicenow
- sitecore
- sonarqube
- specflow
- tfs
- tfs15
- tfs2015
- teambuild
- teamfoundationserver
- tools
- training
- vscode
- vsts
- visualstudio
- wpf
- wiki
- winrm
- windows mobile
- xaml
- acr
- actions
- angularjs
- azure
- bash
- build
- burndown
- container
- cosmos
- csharp
- dependabot
- devops
- dotnet
- dotnetcore
- github
- helm
- ie
- mvc
- packages
- productivity
- quartz.net
- registry
- shell
- synology
- windows
- workitem
- wsl
- wsl2