Enabling WinRM / Remote Powershell on Azure Resource Manager Windows OS VMs

powershell-logoNote: these instructions only apply to Windows VMs created using Azure Resource Manager. For VMs created in Azure Classic mode (old portal at http://manage.windowsazure.com), WinRM / Remote Powershell is enabled by default for certified Windows images.

If you need WinRM (required to run remote Powershell commands) enabled on new Windows Virtual Machines created using Azure Resource Manager, you have two options:

1. Deploy your instance using the 201-vm-winrm-windows quick start ARM template located here. It creates a self signed certificate and configures all the firewall rules to accept HTTP and HTTPS connections in ports 5895 and 5896 (required by WinRM / Remote Powershell). You are done.

2. For VMs already deployed on Azure under the Resource Manager platform, and that were created using base or custom Windows OS images, do the following:

  • Remote Desktop into the virtual machine (which is enabled by default when VMs are created using the portal).
  • From the quick start template located here, copy the ConfigureWinRM.ps1, winrmconf.cmd and makecert.exe files to a local directory in the VM.
  • Using Powershell, go to the folder where you copied these three files and execute the ConfigureWinRM.ps1 script.
  • For the hostname, provide the exact FQDN that you used when the virtual machine was originally created.
  • You are done!

Now you can remotely connect to your machine using Powershell and the Enter-PSSession cmdlet. Also, this is required if you are trying to certificate your image for the Azure Marketplace using the corresponding tool.

Happy clouding!

Software Architect with more than 20 years of experience designing and creating online / cloud enterprise applications, specialized in Microsoft Azure.

Facebook LinkedIn Google+ YouTube Skype 

Share

Posted in: All Posts, Development

Tags: , , , , ,