Remote PowerShell in Azure IAAS Virtual Machines

We can configure remote PowerShell feature while spinning up a new IAAS (Infrastructure as a service) VM.

This enables us to execute PS commands remotely on Azure IAAS VM from our local machine.

This option is available when you create a virtual machine using the "From Gallery" option on the management portal as shown below :

The last step of the wizard displays the option of PowerShell as shown below :

A default firewall endpoint will be created for the deployment.

This enables you to have the VM immediately configured and ready to use without ever having to RDP into the instance.

Start a new Powershell console on your local machine and use the Enter-PSSession command as shown below :

Enter-PSSession –ComputerName <server name> -UseSSL -Credential(Get-Credential)

You will get the below error when you try to connect to the IAAS VM remotely via PS :

This is because Remote PS uses HTTPS and the certificate used for your Virtual Machine is a self signed certificate.

To solve this open your browser and navigate to your VM and the public endpoint for Remote PS.

Eg :

We don't find the certificate button on IE, hence used chrome. Install the certificate under “Current User” and then “Trusted root authority”.

Go to Details tab -> Copy to file -> save the file on your machine.

Double click the file -> Install it under "Current User" -> "Trusted Root Certification Authorities"


After, you will be able to connect to the Azure VM via PS as shown below :



Azure VM is up and running, but RDP fails - Try the below work around which uses remote powershell as explained.

> uvnc is a 3rd party tool : Download and save the exe file on your machine using the below link : 


> Create a txt file with the below content and name it as setup.txt -

   Dir=C:\Program Files\uvnc bvba\UltraVNC

> Please find the configuration file "UltraVNC.ini" file attached.

> Upload the 3 files to your storage account and mark the container as public.

> Add 2 endpoint for ports 5800 and 5900 for the VM on the portal.

Execute the below PS commands in sequence -

    $source = "http://<Your storage account name><Container name>/UltraVNC_1_1_9_X64_Setup.exe"

    $dest = "C:\Users\<User name>\ultravnc.exe"

    $wc = New-Object System.Net.WebClient



    $source2 = "http://<Your storage account name><Container name>/setup.txt"

    $dest2 = "C:\Users\<User name>\setup.txt"

    $wc = New-Object System.Net.WebClient



    .\UltraVNC.exe /silent/loadinf="setup.txt"


    $source1 = "http://<Your storage account name><Container name>/UltraVNC.ini"

    $dest1 = "C:\Program Files\uvnc bvba\UltraVNC\UltraVNC.ini"

    $wc = New-Object System.Net.WebClient



    netsh advfirewall firewall add rule name='VNC5800' dir=in protocol=TCP localport=5800 action=allow profile=any

    netsh advfirewall firewall add rule name='VNC5900' dir=in protocol=TCP localport=5900 action=allow profile=any

    net stop uvnc_service

    net start uvnc_service


Install “UltraVNC Viewer” on your local machine.

Open the viewer tool and provide the VIP address in the text box.

Type the password as “azurevnc”. You will be connected to the VM.

Click on the left hand top button “Ctrl + Alt + Del” and type the RDP password.

Sample PS screenshot -

NOTE : This will work only if the VM is up and running, but RDP fails.

Telnet to 5986 must be successful – This will allow us to install the uvnc server tool on the VM using PS remoting.

There are some known issues with uvnc tool :

There is no license required to use this tool.


Comments (5)

  1. Ken Ross says:

    For reasons unknown my Azure VM suddenly stopped responding to RDP connections. I'm hosting a website + SQL up there and the site continued to run just fine…but I couldn't get to it. Rebooting the the VM still didn't bring RDP back. After much searching around I found your article. YOU.SAVED.MY.BUTT!!  While the instructions might seem a bit long, they DO work and after a bit of time you'll have VNC access to your VM. Awesome.

    The one small edit I'll point out to anyone not that familiar with the PowerShell commands and doing a lot of copy/paste from the article [like me], the command for launching the VNC installer (.UltraVNC.exe /silent/loadinf="setup.txt") needs to have a space between "silent" and /loadinf (.UltraVNC.exe /silent /loadinf="setup.txt"). If you try to run it without the space as-is, the command will fail and appear to just lock up (ctrl+C will get you out). If it executes correctly it will take less than a minute.

  2. Thea says:

    Thanks for this procedure but I'm stuck to the last step: the password azurevnc is not working. Could you confirm that this is the good one? Thanks.

  3. Jared Gohr says:

    This article worked for me. Any reason why adding the azure vm to the WSMan TrustedHosts list doesn't work for azure vms?

  4. ken4me says:


    I'm having the same problem of RDP to azure account.

    Since I'm newer to azure, how to "Upload the 3 files to your storage account and mark the container as public"?


  5. ken4me says:

    ok .I have successfully followed the above steps.

    But once I try to connect through VNC, "Failed to connect to server !" popups.


    Please help me on this.

Skip to main content