The why

While running Virtual Machines in Azure it may be hard to troubleshoot the more difficult issues since boot menu options etc. aren’t visible. That’s where the Virtual Machine Serial Console comes in use. It’s a command line that uses the COM1 Serial Interface of your VM, both for Linux and Windows . This allows you to operate and troubleshoot the Virtual Machine via the Azure portal regardless of its state.

For Server Images created before February 2018 you’ll have to enable EMS (Emergency Management Services) first. To do so, go to the VM in the Azure Portal, select “Run command” and run the EnableEMS command. To do this manually via the VM open the command prompt and run the following two commands:
bcdedit /ems {current} on
bcdedit /emssettings EMSPORT:1 EMSBAUDRATE:11520

The how

Go to the VM in the Azure Portal and select “Serial Console”. In the Special Administrative Console (SAC) that shows up type “cmd” to setup a CMD channel followed by “ch -si 0001” to open that channel:

Once you are in the CMD channel press any key to view the channel:

Login to the VM session with either a local or domain account:

Once successfully logged in you’ll be in the CMD line of the VM. You can perform all actions you’re used to using in the CMD. In the below example we’re requesting the hostname, disabling the firewall of the VM and repairing file corruption.

You can also call the Powershell interface by typing “Powershell” and run cmdlets from there.

Safe mode

One more cool thing is that you can boot your VM into safe mode with this. To do so, first enable the boot menu using the command “bcdedit /set {bootmgr} displaybootmenu yes” and give a reboot using “shutdown /r”.

In a few seconds your VM will reboot and when the boot menu is visible you can select the F8 key as displayed below to get the advanced options like “Safe mode” etc. This is particularly useful when having to repair file corruption with commands like “sfc /scannow” or “dism /online /cleanup-image /restorehealth”.

Synopsis

The Serial Console is a welcome solution for all kinds of scenarios including but absolutely not limited to file corruption, RDP, firewall and bootloader issues. Did you use it and if so, what scenario did you use it for?

Leave a comment

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.

%d bloggers like this: