To reset a local admin password, you need first to define the virtual machine that you need to work with. To do this, you can use the Get-AzureRmVm command, coupled with Set-AzureRmVMAccessExtension. Run the following four commands to set up the variables needed to reset the admin password on myVM1:
$resourceGroupName = "VMLab"
$vmName = "myVM1"
$name = "ResetPassword"
$location = "EastUS"
Once you've set up the variables using the preceding commands, update the local admin credentials for the virtual machine by running the following command:
$creds = Get-Credential
When prompted for credentials, supply the existing local admin username but give it a new password.
After supplying the new local admin credentials, run the Set-AzureRmVMAccessExtension command to actually set the new credentials on the virtual machine:
Set-AzureRmVMAccessExtension `
-ResourceGroupName $resourceGroupName `
-VMName $vmName `
-Name $name `
-Location $location `
-Credential $creds `
-TypeHandlerVersion "2.0"
Once this is complete, the username will have a new password! This technique is useful if you're able to authenticate to your Azure subscription but have forgotten the local password on a virtual machine.