Thursday, January 29, 2015

Reset user name and password of Windows virtual machines on Microsoft Azure

We need to user Remote Desktop to connect a virtual machine on Microsoft Azure. In case we forgot the user name and password of the virtual machine, we can use Azure PowerShell to reset the user name and password. To reset user name and password of a virtual machine, we can perform Set-AzureVMAccessExtension to update the user name and password of a virtual machine.

Prerequisites
  • Make sure there is a Azure PowerShell module on your computer
1. First, we can perform Add-AzureAccount to connect Microsoft Azure Account.
2. Then, perform $vm = Get-AzureVM -ServiceName <Cloud service name> -Name <VM Name>.



3. Perform Set-AzureVMAccessExtension -VM $vm -UserName <New user name or existing user name> -Password <new password> -ReferenceName VMAccessAgent | Update-AzureVM to apply the user name and password of the virtual machine.


Remark: No matter the virtual machine is running or not, this cmdlet can update the user name and password of the virtual machine when it restarts.

Remark: If you apply a new user name to the virtual machine, the existing user name for Remote Desktop is deleted automatically.

To check the "ReferenceName", we can perform Get-AzureVM -ServiceName labmachine01 -Name labmachine01 | Get-AzureVMAccessExtension to check it.


After restating the virtual machine, the virtual machine has been applied the updated user name and password.


More information

This posting is provided “AS IS” with no warranties, and confers no rights!

No comments:

Post a Comment