PowerShell Remoting to Azure VM

In order to connect to an Azure Windows VM (tested image was 2016 core with Containers), perform the following:

  1. On the Azure VM, add a firewall rule to allow remote management traffic inbound: New-NetFirewallRule -Name PSRemote -DisplayName ‘PS Remoting’ -Enabled true -Profile any -Direction Inbound -LocalPort 5985 -Protocol TCP
    1. For Nano server, run the following command: []: PS C:\Users\jason\Documents> netsh advfirewall firewall add rule name=”PSRemote” dir=in action=allow protocol=TCP localport=5985
  2. On your local machine, add the VM IP address to your TrustedHosts list: winrm s winrm/config/client ‘@{TrustedHosts=”″}’
  3. In the Azure management console, add an inbound security rule to the associated Network Security Group for port 5985.
  4. At this point, you will be able to connect to your Azure VM remotely from PowerShell: Enter-PSSession -Credential userName


For future reference on Windows 2016 Containers: https://msdn.microsoft.com/virtualization/windowscontainers/quick_start/manage_powershell

Leave a Reply