Reset Remote Desktop Services or its administrator password in a Windows VM

If you can't connect to a Windows virtual machine (VM), you can reset your local administrator password or reset the Remote Desktop Services configuration (not supported on Windows domain controllers). To reset the password, use either the Azure portal or the VM Access extension in Azure PowerShell. After you've signed in to the VM, reset the password for that local administrator.
If you're using PowerShell, make sure that you have the latest PowerShell module installed and configured and are signed in to your Azure subscription. You can also perform these steps for VMs created with the classic deployment model.

You can reset Remote Desktop Services and credentials in the following ways:

Reset by using the Azure portal

First, sign in to the Azure portal and then select Virtual machines on the left menu.

Reset the local administrator account password

  1. Select your Windows VM and then select Reset password under Support + Troubleshooting. The Reset password window is displayed.

  2. Select Reset password, enter a username and a password, and then select Update.

  3. Try connecting to your VM again.

Reset the Remote Desktop Services configuration

  1. Select your Windows VM and then select Reset password under Support + Troubleshooting. The Reset password window is displayed.

  2. Select Reset configuration only and then select Update.

  3. Try connecting to your VM again.

Reset by using the VMAccess extension and PowerShell

First, make sure that you have the latest PowerShell module installed and configured and are signed in to your Azure subscription by using the Connect-AzureRmAccount cmdlet.

Reset the local administrator account password

  • Reset the administrator password or user name with the Set-AzureRmVMAccessExtension PowerShell cmdlet. The typeHandlerVersion setting must be 2.0 or greater, because version 1 is deprecated.

    $SubID = "<SUBSCRIPTION ID>" 
    $RgName = "<RESOURCE GROUP NAME>" 
    $VmName = "<VM NAME>" 
    $Location = "<LOCATION>" 
    
    Connect-AzureRmAccount 
    Select-AzureRMSubscription -SubscriptionId $SubID 
    Set-AzureRmVMAccessExtension -ResourceGroupName $RgName -Location $Location -VMName $VmName -Credential (get-credential) -typeHandlerVersion "2.0" -Name VMAccessAgent 
    

    Note

    If you enter a different name than the current local administrator account on your VM, the VMAccess extension will add a local administrator account with that name, and assign your specified password to that account. If the local administrator account on your VM exists, the VMAccess extension will reset the password. If the account is disabled, the VMAccess extension will enable it.

Reset the Remote Desktop Services configuration

  1. Reset remote access to your VM with the Set-AzureRmVMAccessExtension PowerShell cmdlet. The following example resets the access extension named myVMAccess on the VM named myVM in the myResourceGroup resource group:

    Set-AzureRmVMAccessExtension -ResourceGroupName "myResoureGroup" -VMName "myVM" -Name "myVMAccess" -Location WestUS -typeHandlerVersion "2.0" -ForceRerun
    

    Tip

    At any point, a VM can have only a single VM access agent. To set the VM access agent properties, use the -ForceRerun option. When you use -ForceRerun, ensure you use the same name for the VM access agent that you might have used in any previous commands.

  2. If you still can't connect remotely to your virtual machine, see Troubleshoot Remote Desktop connections to a Windows-based Azure virtual machine. If you lose the connection to the Windows domain controller, you will need to restore it from a domain controller backup.

Next steps