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.
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”
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.
Using the i command we can get the IP Address configuration of the VM
To create a command prompt session, first enter “cmd”. This will create a session.
To list the cmd sessions press “ch”
to select & login to a cmd session press “ch -si #” where # is the channel number. At the below screen press Enter
At the next screen enter the admin credentials
and we have Command Prompt. At this command prompt we can use all cmd commands.
at the command prompt enter “powershell” and press Enter to open a PowerShell Session
PowerShell example, disable windows firewall:
Set-NetFirewallProfile -Profile Domain,Public,Private -Enabled False
and yes, its off
of course, for the firewall we could disable it using CMD
netsh advfirewall set allprofiles state off
For more example commands follow this link: https://docs.microsoft.com/en-us/azure/virtual-machines/troubleshooting/serial-console-cmd-ps-commands
Pantelis Apostolidis is a Cloud Solutions Architect at Microsoft and an ex Microsoft Azure MVP. For the last 15 years, Pantelis has been involved to major cloud projects in Greece and abroad, helping companies to adopt and deploy cloud technologies, driving business value. He is entitled to a lot of Microsoft Expert Certifications, demonstrating his proven experience in delivering high quality solutions. He is an author, blogger and he is acting as a spokesperson for conferences, workshops and webinars. He is also an active member of several communities as a moderator in azureheads.gr and autoexec.gr. Follow him on Twitter @papostolidis.