How to reset password in Azure virtual machine

In this azure tutorial, we will discuss the Azure virtual machine reset password. Apart from this, we will also discuss on the below topics:

  • Azure virtual machine reset password using PowerShell
  • The Azure VM reset configuration
  • Azure virtual machine reset configuration using PowerShell

How to reset password in Azure virtual machine

Let’s discuss how can we reset the password of the virtual machine in Azure portal.

You can follow the below steps to reset password for virtual machine

Step- 1: 

Login to https://portal.azure.com/

Step- 2: 

Search for Virtual machines there.

Azure virtual machine reset password

Step- 3: 

 You will see the list of VM created in your Azure subscription. It will show the VM name, Type, Status, ResourceGroup, Location, etc.

Azure virtual machine reset password using Azure portal

Step- 4: 

Now click on the VM name. “MyNewVM” in my case. You can able to see the details of your virtual machine like Public IP address, status, Computer name, Operating system, Size etc.

How to reset the password of the Azure virtual machine

Step- 5:

From the left side menu select Reset password option under support + troubleshooting.

Azure virtual machine reset password using Azure portal

Step- 6:

If you will see in the below screen the Reset password option is disabled and it is saying “The virtual machine must be running before using VMAccess

How to reset the password of the Azure virtual machine

This is because may be my VM status is Stopped (deallocated) or not running. Let’s check that.

You can see below the VM status is Stopped (deallocated). Now click on the start button then after the VM status will be Running.

How to reset the password of the Azure virtual machine

Step- 7:

Now if you will click on the Reset password option again. You can able to see the Reset Password option is enabled.

Choose the Mode as Reset password.

Enter the username,Password and confirm password and then click on the Update button.

Reset password option in Azure VM

This is how you can reset your VM password from the Azure portal.

Azure virtual machine reset password using PowerShell

Step- 1:

First connect to the Azure account using the below command.

Connect-AzAccount 

Step- 2:

Select the Azure subscription ID

$MySubID = "<Mention Your Subscription ID>"
Select-AzSubscription -SubscriptionId $MySubID 

Step- 3:

Set the Set-AzVMAccessExtension to reset the username or password.

$MyResourceGroup = "<Mention your Resource group name>" 
$MyVmName = "<Mention your VM name>" 
$MyLocation = "<Mention your VM Location>" 

Set-AzVMAccessExtension -ResourceGroupName $MyResourceGroup -Location $MyLocation -VMName $MyVmName -Credential (get-credential) -typeHandlerVersion "2.0" -Name VMAccessAgent 

Now below is the complete powershell script

$MySubID = "<Mention Your Subscription ID>"
$MyResourceGroup = "<Mention your Resource group name>" 
$MyVmName = "<Mention your VM name>" 
$MyLocation = "<Mention your VM Location>" 

Connect-AzAccount 
Select-AzSubscription -SubscriptionId $MySubID
Set-AzVMAccessExtension -ResourceGroupName $MyResourceGroup -Location $MyLocation -VMName $MyVmName -Credential (get-credential) -typeHandlerVersion "2.0" -Name VMAccessAgent 

Azure virtual machine reset configuration

This step will reset the RDP configuration.

Step- 1: To do this, select your VM from the Azure portal and from the left menu from Support + troubleshooting section, select the “Reset password” button

Azure virtual machine reset configuration

Step- 2: Now the below window will open, select the mode as “Reset configuration only” and then click on the “Update” button.

How to do Azure virtual machine reset configuration

Azure virtual machine reset configuration using PowerShell

You can use the below powershell script to reset the configuration of your virtual machine

$MyResourceGroup = "<Mention your Resource group name>" 
$MyVmName = "<Mention your VM name>" 
$VMAccessname = "<Mention your VM access name>" 
$MyLocation = "<Mention your VM Location>"

Set-AzVMAccessExtension -ResourceGroupName $MyResourceGroup -VMName $MyVmName -Name $VMAccessname -Location $MyLocation -typeHandlerVersion "2.0" -ForceRerun

You may like following Azure tutorials:

Conclusion

In this Azure tutorial, We discussed

  • Azure virtual machine reset password using PowerShell
  • The Azure VM reset configuration
  • Azure virtual machine reset configuration using PowerShell

Leave a Comment