The Reset password utility for Virtual Machines has come in handy on the odd occasion when we never recorded or misplaced the password for a VM running in Azure. The downside is this tool does not support running against Domain Controllers (to reset the in-built Administrator account). So what happens when you have a domain controller, that only has a single Domain Admin account and we’ve forgotten the password? In comes Virtual Machines Extensions to the rescue. Firstly, open up Notepad and enter a net user reset password command like below replacing the username and password with the one you want to reset. Save it as script.ps1
net user <Username> <Password>
Log into the Azure Portal and then select the Virtual Machine you want to change domain password for, under the main menu blade for that Virtual Machine find Extensions and enter it. We now want to add in a new Extension so click on the +Add button at the top, in the Add Extension blade, find and select Script Extension and click on Create.
This will now allow us to upload the script.ps1 we created earlier, so browse to it and then hit Upload. This will then trigger the script to run in the Virtual Machine and we’ll get notified when it is created and run.