Using the Serial Console on Windows IaaS VMs

Published Apr 15 2021 03:00 AM 3,189 Views
Microsoft

If you make a mistake when configuring operating system firewall rules that block you from accessing the VM, or a service is stopping an IaaS VM from booting, or some other configuration problem such as a newly installed application is stopping you from accessing a Windows Server IaaS VM using RDP or remote PowerShell, you always have the option of interacting with the Special Administration Console (SAC), also known as Emergency Management Services (EMS) if you set it up beforehand.

 

Enabling EMS can provide you with another “get out of jail” card if something goes wrong with one of your Windows Server IaaS VMs.

Note: Serial Console access is also available for Linux VMs, and you can find out more about it in the following Docs article: 

 

There are several steps that you need to take to enable Serial Console access to Windows Server IaaS VMs. The first is to configure the Windows Server VM operating system to support EMS, something that it isn’t configured for by default. You can do this by opening up an administrative command prompt (not PowerShell) on the VM once it is deployed and running the command:

 

 

Bcdedit /ems {current} on

 

You’ll then need to restart the VM.

 

When configuring Serial Console for a VM, you also need to ensure that you have an account configured as a member of the local Administrators group on the VM that uses password authentication. This is the account you’ll use to interact with the VM through EMS once you have authenticated.

 

The next step requires that you configure the VM to support boot diagnostics. It’s important to note that you’ll need to use a custom boot diagnostics account and that you can’t use managed boot diagnostics storage accounts at the time of writing. You can do this from CloudShell by running the command (substituting in the appropriate values for VM name, resource group and storage account that will store boot diagnostics data):

 

 

az vm boot-diagnostics enable --name MyVirtualMachine --resource-group MyResourceGroup --storage https://mystor.blob.core.windows.net/

 

Or by enabling it through the VM’s properties in the Azure portal in the Boot Diagnostics area of the Support + Troubleshooting section.

Once you’ve enabled boot diagnostics, the final step is to enable Serial Console at the subscription level. You can do this in CloudShell by running the following commands:

 

 

subscriptionId=$(az account show --output=json | jq -r .id)

az resource invoke-action --action enableConsole --ids "/subscriptions/$subscriptionId/providers/Microsoft.SerialConsole/consoleServices/default" --api-version="2018-05-01"

 

Once you’ve taken these steps you can access the Serial Console for the VM from the Serial Console area of the Support + Troubleshooting section.

 

OrinThomas_0-1618404341356.png

 

Once you’ve made the connection to SAC, enter the following to create a channel that has the CMD instance

 

 

Cmd

 

You’ll then need to type the following to switch to the cmd channel

 

 

Ch -si 1

 

 

Press Enter and you’ll be presented with an authentication prompt. Authenticate with the account that has local credentials. Generally you’ll just press Enter when prompted for Domain and if you have to delete characters when authenticating, press <CTRL><H>

To start a PowerShell session from the command prompt, type PowerShell.exe

 

OrinThomas_1-1618404341382.png

 

You can use PowerShell within a Serial Console to perform the following tasks:

  • Edit the registry
  • Enable RDP
  • Manage services
  • Configure service logon accounts
  • Configure service startup types
  • Configure service dependencies
  • Perform network diagnostics
  • Manage Windows Firewall settings
  • Manage users and groups
  • Manage the Windows Event Log
  • View or remove installed applications
  • Add and remove Windows roles and features
  • Restart windows
  • Configure network interfaces including setting IP addresses (remember that an Azure IaaS VM should always be configured from within the VM to use DHCP and any adapter address configuration should be performed external to the VM against the network adapter within the Azure console)

For more information on what you can do using cmd.exe and PowerShell within a Serial Console session, consult the following article: 

 

Although you’ll probably not need it, you should enable EMS on all of your Windows Server IaaS VMs as a way of giving yourself a method of troubleshooting a VM you can’t connect to using RDP or Azure PowerShell.

%3CLINGO-SUB%20id%3D%22lingo-sub-2272295%22%20slang%3D%22en-US%22%3EUsing%20the%20Serial%20Console%20on%20Windows%20IaaS%20VMs%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2272295%22%20slang%3D%22en-US%22%3E%3CP%3EIf%20you%20make%20a%20mistake%20when%20configuring%20operating%20system%20firewall%20rules%20that%20block%20you%20from%20accessing%20the%20VM%2C%20or%20a%20service%20is%20stopping%20an%20IaaS%20VM%20from%20booting%2C%20or%20some%20other%20configuration%20problem%20such%20as%20a%20newly%20installed%20application%20is%20stopping%20you%20from%20accessing%20a%20Windows%20Server%20IaaS%20VM%20using%20RDP%20or%20remote%20PowerShell%2C%20you%20always%20have%20the%20option%20of%20interacting%20with%20the%20Special%20Administration%20Console%20(SAC)%2C%20also%20known%20as%20Emergency%20Management%20Services%20(EMS)%20if%20you%20set%20it%20up%20beforehand.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EEnabling%20EMS%20can%20provide%20you%20with%20another%20%E2%80%9Cget%20out%20of%20jail%E2%80%9D%20card%20if%20something%20goes%20wrong%20with%20one%20of%20your%20Windows%20Server%20IaaS%20VMs.%3C%2FP%3E%0A%3CP%3ENote%3A%20Serial%20Console%20access%20is%20also%20available%20for%20Linux%20VMs%2C%20and%20you%20can%20find%20out%20more%20about%20it%20in%20the%20following%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Ftroubleshoot%2Fazure%2Fvirtual-machines%2Fserial-console-linux%3FWT.mc_id%3Dmodinfra-24286-orthomas%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%22%3E%20Docs%20article%3A%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThere%20are%20several%20steps%20that%20you%20need%20to%20take%20to%20enable%20Serial%20Console%20access%20to%20Windows%20Server%20IaaS%20VMs.%20The%20first%20is%20to%20configure%20the%20Windows%20Server%20VM%20operating%20system%20to%20support%20EMS%2C%20something%20that%20it%20isn%E2%80%99t%20configured%20for%20by%20default.%20You%20can%20do%20this%20by%20opening%20up%20an%20administrative%20command%20prompt%20(not%20PowerShell)%20on%20the%20VM%20once%20it%20is%20deployed%20and%20running%20the%20command%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-bash%22%3E%3CCODE%3EBcdedit%20%2Fems%20%7Bcurrent%7D%20on%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EYou%E2%80%99ll%20then%20need%20to%20restart%20the%20VM.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EWhen%20configuring%20Serial%20Console%20for%20a%20VM%2C%20you%20also%20need%20to%20ensure%20that%20you%20have%20an%20account%20configured%20as%20a%20member%20of%20the%20local%20Administrators%20group%20on%20the%20VM%20that%20uses%20password%20authentication.%20This%20is%20the%20account%20you%E2%80%99ll%20use%20to%20interact%20with%20the%20VM%20through%20EMS%20once%20you%20have%20authenticated.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20next%20step%20requires%20that%20you%20configure%20the%20VM%20to%20support%20boot%20diagnostics.%20It%E2%80%99s%20important%20to%20note%20that%20you%E2%80%99ll%20need%20to%20use%20a%20custom%20boot%20diagnostics%20account%20and%20that%20you%20can%E2%80%99t%20use%20managed%20boot%20diagnostics%20storage%20accounts%20at%20the%20time%20of%20writing.%20You%20can%20do%20this%20from%20CloudShell%20by%20running%20the%20command%20(substituting%20in%20the%20appropriate%20values%20for%20VM%20name%2C%20resource%20group%20and%20storage%20account%20that%20will%20store%20boot%20diagnostics%20data)%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-bash%22%3E%3CCODE%3Eaz%20vm%20boot-diagnostics%20enable%20--name%20MyVirtualMachine%20--resource-group%20MyResourceGroup%20--storage%20https%3A%2F%2Fmystor.blob.core.windows.net%2F%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EOr%20by%20enabling%20it%20through%20the%20VM%E2%80%99s%20properties%20in%20the%20Azure%20portal%20in%20the%20Boot%20Diagnostics%20area%20of%20the%20Support%20%2B%20Troubleshooting%20section.%3C%2FP%3E%0A%3CP%3EOnce%20you%E2%80%99ve%20enabled%20boot%20diagnostics%2C%20the%20final%20step%20is%20to%20enable%20Serial%20Console%20at%20the%20subscription%20level.%20You%20can%20do%20this%20in%20CloudShell%20by%20running%20the%20following%20commands%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-bash%22%3E%3CCODE%3EsubscriptionId%3D%24(az%20account%20show%20--output%3Djson%20%7C%20jq%20-r%20.id)%0A%0Aaz%20resource%20invoke-action%20--action%20enableConsole%20--ids%20%22%2Fsubscriptions%2F%24subscriptionId%2Fproviders%2FMicrosoft.SerialConsole%2FconsoleServices%2Fdefault%22%20--api-version%3D%222018-05-01%22%0A%0A%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EOnce%20you%E2%80%99ve%20taken%20these%20steps%20you%20can%20access%20the%20Serial%20Console%20for%20the%20VM%20from%20the%20Serial%20Console%20area%20of%20the%20Support%20%2B%20Troubleshooting%20section.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22OrinThomas_0-1618404341356.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F272782i9D49CB359F463966%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22OrinThomas_0-1618404341356.png%22%20alt%3D%22OrinThomas_0-1618404341356.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EOnce%20you%E2%80%99ve%20made%20the%20connection%20to%20SAC%2C%20enter%20the%20following%20to%20create%20a%20channel%20that%20has%20the%20CMD%20instance%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-bash%22%3E%3CCODE%3ECmd%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EYou%E2%80%99ll%20then%20need%20to%20type%20the%20following%20to%20switch%20to%20the%20cmd%20channel%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-bash%22%3E%3CCODE%3ECh%20-si%201%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EPress%20Enter%20and%20you%E2%80%99ll%20be%20presented%20with%20an%20authentication%20prompt.%20Authenticate%20with%20the%20account%20that%20has%20local%20credentials.%20Generally%20you%E2%80%99ll%20just%20press%20Enter%20when%20prompted%20for%20Domain%20and%20if%20you%20have%20to%20delete%20characters%20when%20authenticating%2C%20press%20%3CCTRL%3E%3CH%3E%3C%2FH%3E%3C%2FCTRL%3E%3C%2FP%3E%0A%3CP%3ETo%20start%20a%20PowerShell%20session%20from%20the%20command%20prompt%2C%20type%20PowerShell.exe%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22OrinThomas_1-1618404341382.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F272783i18258DF46313EA3B%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22OrinThomas_1-1618404341382.png%22%20alt%3D%22OrinThomas_1-1618404341382.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EYou%20can%20use%20PowerShell%20within%20a%20Serial%20Console%20to%20perform%20the%20following%20tasks%3A%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3EEdit%20the%20registry%3C%2FLI%3E%0A%3CLI%3EEnable%20RDP%3C%2FLI%3E%0A%3CLI%3EManage%20services%3C%2FLI%3E%0A%3CLI%3EConfigure%20service%20logon%20accounts%3C%2FLI%3E%0A%3CLI%3EConfigure%20service%20startup%20types%3C%2FLI%3E%0A%3CLI%3EConfigure%20service%20dependencies%3C%2FLI%3E%0A%3CLI%3EPerform%20network%20diagnostics%3C%2FLI%3E%0A%3CLI%3EManage%20Windows%20Firewall%20settings%3C%2FLI%3E%0A%3CLI%3EManage%20users%20and%20groups%3C%2FLI%3E%0A%3CLI%3EManage%20the%20Windows%20Event%20Log%3C%2FLI%3E%0A%3CLI%3EView%20or%20remove%20installed%20applications%3C%2FLI%3E%0A%3CLI%3EAdd%20and%20remove%20Windows%20roles%20and%20features%3C%2FLI%3E%0A%3CLI%3ERestart%20windows%3C%2FLI%3E%0A%3CLI%3EConfigure%20network%20interfaces%20including%20setting%20IP%20addresses%20(remember%20that%20an%20Azure%20IaaS%20VM%20should%20always%20be%20configured%20from%20within%20the%20VM%20to%20use%20DHCP%20and%20any%20adapter%20address%20configuration%20should%20be%20performed%20external%20to%20the%20VM%20against%20the%20network%20adapter%20within%20the%20Azure%20console)%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3EFor%20more%20information%20on%20what%20you%20can%20do%20using%20cmd.exe%20and%20PowerShell%20within%20a%20Serial%20Console%20session%2C%20consult%20the%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Ftroubleshoot%2Fazure%2Fvirtual-machines%2Fserial-console-cmd-ps-commands%3FWT.mc_id%3Dmodinfra-24286-orthomas%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%22%3Efollowing%20article%3A%26nbsp%3B%3C%2FA%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EAlthough%20you%E2%80%99ll%20probably%20not%20need%20it%2C%20you%20should%20enable%20EMS%20on%20all%20of%20your%20Windows%20Server%20IaaS%20VMs%20as%20a%20way%20of%20giving%20yourself%20a%20method%20of%20troubleshooting%20a%20VM%20you%20can%E2%80%99t%20connect%20to%20using%20RDP%20or%20Azure%20PowerShell.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-2272295%22%20slang%3D%22en-US%22%3E%3CP%3EThe%20serial%20console%20for%20Windows%20IaaS%20VM%20in%20Azure%20gives%20you%20another%20way%20of%20accessing%20a%20VM%20that%20you%20can't%20otherwise%20connect%20to%2C%20but%20you%20have%20to%20have%20it%20set%20up%20before%20things%20go%20wrong!%3C%2FP%3E%3C%2FLINGO-TEASER%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2272295%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EAzure%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EWindows%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Co-Authors
Version history
Last update:
‎Apr 14 2021 05:51 AM
Updated by: