Azure VM CMD & PowerShell from the Portal

Azure VM CMD & PowerShell from the Portal

Today I was trying to troubleshoot an Azure VM. This VM is behind a Network Virtual Appliance (NVA) and at the subnet it has User Defined Routes (UDR) that routes the traffic to the NVA. We was troubleshooting the NVA and it was not possible to connect with RDP to the VM.

Serial Console

This is an excellent scenario to use the Serial Console. From the Azure Portal, portal.azure.com, navigate to the Azure VMs blade, scroll down to the Support + Troubleshooting section and select “Serial Console”

azure vm cmd & powershell

The Serial Console will initialise and after a while it will establish the connection and the prompt will be the SAC>. If you encounter any errors establishing the SAC link, please follow this link: https://aka.ms/serialconsolewindows

At the SAC> prompt press help to list the available commands.

azure vm cmd & powershell

Using the i command we can get the IP Address configuration of the VM

azure vm cmd & powershell

Command Prompt

To create a command prompt session, first enter “cmd”. This will create a session.

azure vm cmd & powershell

To list the cmd sessions press “ch”

azure vm cmd & powershell

to select & login to a cmd session press “ch -si #” where # is the channel number. At the below screen press Enter

azure vm cmd & powershell

At the next screen enter the admin credentials

azure vm cmd & powershell

and we have Command Prompt. At this command prompt we can use all cmd commands.

azure vm cmd & powershell

Some examples:

ping -t

azure vm cmd & powershell

dir

azure vm cmd & powershell

enable telnet client:

dism /online /Enable-Feature /FeatureName:TelnetClient

PowerShell

at the command prompt enter “PowerShell” and press Enter to open a PowerShell Session

azure vm cmd & powershell

PowerShell example, disable windows firewall:

Set-NetFirewallProfile -Profile Domain,Public,Private -Enabled False

azure vm cmd & powershell

and yes, its off

azure vm cmd & powershell

of course, for the firewall we could disable it using CMD

netsh advfirewall set allprofiles state off

PowerShell for conenction test: Test-NetConnection -Computername “hostname,IP,URL” -Port “portNumber”

For more example commands follow this link: https://docs.microsoft.com/en-us/azure/virtual-machines/troubleshooting/serial-console-cmd-ps-commands

Share

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.