Jump to content













Photo
- - - - -

Azure VM CMD & PowerShell from the Portal

  Posted by Pantelis Apostolidis , in Azure 06 June 2019 · 51 views

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”

Posted Image

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.

Posted Image

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

Posted Image
Command Prompt
To create a command prompt session, first enter “cmd”. This will create a session.

Posted Image

To list the cmd sessions press “ch”

Posted Image

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

Posted Image

At the next screen enter the admin credentials

Posted Image

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

Posted Image

Some examples:

ping -t

Posted Image

dir

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

https://www.e-aposto...f8f14e24299.png

PowerShell example, disable windows firewall:

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

https://www.e-aposto...f8f34463a54.png

and yes, its off

https://www.e-aposto...f8f3609d243.png

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.microso...cmd-ps-commands