Reset the local administrator password for Azure VM?

EnterpriseArchitect 6,391 Reputation points
2025-05-02T06:05:53.3+00:00

How can I log in and reset the local admin password on an Azure Windows VM running Windows Server 2016?

I have a Windows Server 2016 VM in my Azure environment that I need to gain control of. It's quite old and has not been patched for thousands of days. Unfortunately, no one knows the local admin username or password.

Additionally, the VM is not joined to an Active Directory domain, which adds to the complexity of the situation.

Azure Virtual Machines
Azure Virtual Machines

An Azure service that is used to provision Windows and Linux virtual machines.


Answer accepted by question author
Alex Burlachenko 25,115 Reputation points MVP Volunteer Moderator
2025-05-05T15:55:55.3166667+00:00

Hi dear collegue EnterpriseArchitect,

thanks for posting your question on the Q&A portal.

To reset the local admin password for your Azure Windows VM (Windows Server 2016), you can use Azure’s built-in Reset Password feature via the Azure Portal, CLI, or PowerShell. Since the VM isn’t domain-joined, this method will work directly.

Azure Portal: Navigate to your VM > Reset password under Support + Troubleshooting.

Azure CLI/PowerShell: Use the az vm user update command.

CLI Docs: az vm user update

If the VM is unhealthy (e.g., unpatched for long), consider using Azure Serial Console or redeploying the VM (last resort):

Serial Console: Troubleshoot with Serial Console

Let me know if you hit any snags!

Best regards,
Alex
P.S. If my answer help to you, please Accept my answer
PPS That is my Answer and not a Comment

Was this answer helpful?

1 person found this answer helpful.

1 additional answer

Sort by: Most helpful
  1. Durga Reshma Malthi 11,600 Reputation points Microsoft External Staff Moderator
    2025-05-02T10:28:06.1733333+00:00

    Hi EnterpriseArchitect

    Could you please follow the below steps to resolve this issue:

    1. Try resetting the local admin password using the Azure portal:
      Azure Portal -> Virtual Machines -> Select your VM -> In the left Menu, select Reset
      Password option and enter the new username and password, then click Update. Try logging into your VM with the new credentials.
    2. Run the following command to create a new local admin user with the username and
      password you specify in Azure PowerShell or Azure CLI:
      az vm user update --resource-group <YourResourceGroup> --name <YourVMName>
      --username <NewAdminUsername> --password <NewStrongPassword>
    3. You can try to reset the password in Azure PowerShell using the Set-AzVMAccessExtension cmdlet:
      Set-AzVMAccessExtension  -ResourceGroupName $RgName  -VMName $VmName 
      -Credential  (Get-Credential)  -TypeHandlerVersion "2.0"  -Name  VMAccessAgent

      If the deployment is successful, log in with the new credentials.
      You can verify the changes by running:
      Get-AzVMExtension -ResourceGroupName "<RESOURCE GROUP>" -VMName "<VM
      NAME>"
    4. If the VM agent isn’t available, you’ll need to reset the password manually:
      Stop the VM in Azure portal -> Create a snapshot of OS disk and make a new disk from it -> Attach the new disk to another windows VM as data disk -> Use Windows tools to modify system files on the attached disk to reset the password
      a. Open Disk Management and locate the attached OS disk. Assign a drive letter to the
      Windows partition. Open CMD in Admin mode and navigate to the attached disk
      (e.g., C:\Windows\System32, replacing C with the assigned drive letter).
      b. Run the following commands to rename Utilman.exe (this allows bypassing login
      security):
      move Utilman.exe Utilman.exe.bak
      copy cmd.exe Utilman.exe

      c. Detach the disk from the working VM once the changes are made. Swap the OS disk with the newly modified disk. Then, Restart the VM.
      d. Run the following command in the cmd to reset the password: net user Administrator NewPassword, And then try to login into your VM with new password. Then you need to Restore system files by renaming Utilman.exe back to its original name: move Utilman.exe.bak Utilman.exe

    Since the VM has not been patched for thousands of days, once you regain access, make sure to apply necessary updates and security patches to safeguard the VM from vulnerabilities.

    Additional references:

    https://learn.microsoft.com/en-us/troubleshoot/azure/virtual-machines/windows/reset-rdp

    https://learn.microsoft.com/en-us/troubleshoot/azure/virtual-machines/windows/reset-local-password-without-agent

    Hope this helps!

    Please Let me know if you have any queries.

    Was this answer helpful?

    2 people found this answer helpful.

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.