locked
Script Help with PowerShell VM Password Reset RRS feed

  • Question

  • Hello Teams!

    An Azure customer @dziedzomdotcom via Twitter is receiving new portal password reset failures and is attempting to reset the VM password using PowerShell. The customer shared the following script and would like some guidance on completing it,.. the questions are placed in the script.


    $adminCredentials = Get-Credential -Message "Hier my Username?"

    $VMName = "Server Name is IP or juste name?";

    $ServiceName = "Server Name is IP or juste name?";

        $VM = Get-AzureVM -Name $VMName -ServiceName $ServiceName

            Set-AzureVMAccessExtention -VM $VM `
                -Username $adminCredentials.UserName `
                -Password $adminCredentials.GetNetworkCredential().Password `
                -ReferenceName "VMAccessAgent"
            Update-AzureVM
            Restart-AzureeVM -ServiceName $ServiceName -Name $VMName

    Thank you for your assistance!

    @AzureSupport

    Tuesday, May 31, 2016 6:00 PM

All replies

  • Hi,

    Please find the suggestions in-line:

    $adminCredentials = Get-Credential -Message "This message will be displayed when you are prompted for your credentials. You could also remove the message part and just say $adminCredentials = Get-Credential"

    $VMName = "This would be your VM/Server/Host name";

    $ServiceName = "This would be the name of the cloud service your VM is a part of";

        $VM = Get-AzureVM -Name $VMName -ServiceName $ServiceName

            Set-AzureVMAccessExtention -VM $VM `
                -Username $adminCredentials.UserName `
                -Password $adminCredentials.GetNetworkCredential().Password `
                -ReferenceName "VMAccessAgent"
            Update-AzureVM
            Restart-AzureeVM -ServiceName $ServiceName -Name $VMName

    Also, the PowerShell Script above would work for a Classic Azure VM.
    If you are using an ARM VM, you could try the following script:

    $cred=Get-Credential
    Set-AzureRmVMAccessExtension -ResourceGroupName "Your Resource Group Name" -VMName "Your VM Name" -Name "Username" -Location "Southeast Asia" -UserName $cred.GetNetworkCredential().Username -Password $cred.GetNetworkCredential().Password

    It worked for me and I was able to reset the admin password. Also, please make sure, you have the latest version of Azure PowerShell.
    You could refer the following link for details:
    https://azure.microsoft.com/en-in/documentation/articles/virtual-machines-windows-reset-rdp/

    Regards,
    Malar.


    Wednesday, June 1, 2016 7:56 AM