Azure Breakthroughs: Finding the Azure VM administrator username

  • Sandro Pereira
  • Nov 4, 2021
  • 3 min read

I usually use a range of different usernames to define as the administrator of my Azure Virtual Machines, and I have others that clients shared with me. So, you may be thinking, why are you accessing the Azure VMs using the administration account and not an AD account? Typically, these are standalone development environments where I need permissions as an administrator, so sometimes, this is the quick and easy way. We may argue if this is the best practice or not, but it is, without a doubt, the fastest and easiest way.

And today, one of my team members called me asking what the password of user ABC (not the real username) was to access one of our Azure BizTalk Server Development VMs, because he was trying all possible variants and was not able to log in. Unfortunately, I don’t remember all the VM administrator usernames I use to create our internal VM, so the first question I asked was not about the password but whether he was using the correct username to access the machine. He was not sure about it either.

So, the main question is: How can you quickly find the Azure VM administrator username of a specific machine?

There may be many ways to find this information. I will highlight here two of them that I normally use.

📝 One-Minute Brief

Recovering access to an Azure virtual machine can be challenging when the administrator username is unknown. This article explains how to identify the configured Azure VM admin account using Azure‑native tools and metadata, helping administrators regain access without rebuilding the virtual machine.

Option 1: Using the Azure Portal

  • Go to Virtual Machines services on your Azure portal.
  • Select the Virtual Machine that you want to find the username.
  • On the Virtual Machine property page, from the option tree, click on the Run command option from the Operations section.
  • On the Run command page, select RunPowerShellScript, and then type Get-LocalUser on the PowerShell Script panel and click Run.
Get-LocalUser
  • The output will be a list of local users present on the machine, mentioning what the administrator is.

Option 2: Using PowerShell

Another easy option is using a simple PowerShell script:

Get-AZVM -Name VM-NAME | Select-Object -ExpandProperty OSProfile

The output of that command will have the Administration username of that VM:

PowerShell command

Download

THIS POWERSHELL SCRIPT IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND.

You can download Finding Azure VM Administrator Username from GitHub here:

Hope you find this helpful! If you liked the content or found it useful and would like to support me in writing more, consider buying (or helping to buy) a Star Wars Lego set for my son. 

Thanks for Buying me a coffe
Author: Sandro Pereira

Sandro Pereira lives in Portugal and works as a consultant at DevScope. In the past years, he has been working on implementing Integration scenarios both on-premises and cloud for various clients, each with different scenarios from a technical point of view, size, and criticality, using Microsoft Azure, Microsoft BizTalk Server and different technologies like AS2, EDI, RosettaNet, SAP, TIBCO etc. He is a regular blogger, international speaker, and technical reviewer of several BizTalk books all focused on Integration. He is also the author of the book “BizTalk Mapping Patterns & Best Practices”. He has been awarded MVP since 2011 for his contributions to the integration community.

Leave a Reply

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

The Ultimate Cloud
Management Platform for Azure

Supercharge your Azure Cost Saving

Learn More
Turbo360 Widget

Back to Top