Sunday, 22 March 2015

Recover Azure VM password (Reset Azure VM password)

If you find you've changed your password on your Azure Virtual Machine, but then subsequently forgotten it (and I swear I was entering the correct password, but apparently not), then you google phrases like "recover azure vm password" etc, you may run across blog posts from Microsoft like the one found here.

There are two things to note which are not entirely obvious from the steps listed there.  One is, if you don't use PowerShell every day you may launch the PowerShell command prompt and not the ISE as they suggest.  You do in fact want the ISE, not the command prompt.  For example on a Windows 2008 server machine the ISE is under Accessories... Windows PowerShell... Windows PowerShell ISE.

The other thing is, if you're trying to reset the password of your VM, the VM actually has to be powered up.  (Duh!)  In retrospect this is obvious; how can you reset the password of your VM if the VM is not actually powered up?  You can't.

But if it is powered up (which you do by going to the Azure management portal, going to "All Items", clicking on the VM in question, and clicking the "Start" button), wait for it to power up (I find I have to refresh the page to actually see the status), then go through the steps in those MS blog posts, then you'll see different behaviour in the PowerShell ISE.  When you get to the last step, to run the snippet that actually resets the machine, you'll be given a list of VMs and you can pick the one you want.  I actually only had one VM so that's the one I picked.  But the behaviour obviously makes much more sense given that the VM is now powered up and able to receive the PowerShell commands that remotely cause its password to be reset for the specified account.

Finally one more thing:  there's a point where they tell you to issue this command:

Select-AzureSubscription –Default $subscription

I actually got an error at that point; PowerShell was complaining about the parameters.  I found that if I simply did not enter the "-Default" parameter it still worked.  In other words I typed

Select-AzureSubscription $subscription

Anyway the procedure did ultimately work and allowed me to reset my password.  It was a relief to find I could still access my VM and didn't have to start from scratch rebuilding it.  (Incidentally if you're not that far along building your VM, you can simply delete the VM and create a new one, but obviously after a certain investment of time that option becomes less attractive).

Update 2015-09-14:  you can now use the windows azure portal user interface to reset your password.  This appears to work well, albeit slowly.





No comments:

Post a Comment