Created
August 13, 2014 16:17
-
-
Save rchaganti/bf5b33edb6813b52cc3b to your computer and use it in GitHub Desktop.
Reset-AzureVMUserPassword
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Function Reset-AzureVMUserPassword { | |
param ( | |
[String] | |
$VMName, | |
[String] | |
$ServiceName, | |
[PSCredential] | |
$Credential | |
) | |
try { | |
$VM = Get-AzureVM -ServiceName $ServiceName -Name $VMName | |
If ($VM.VM.ProvisionGuestAgent) { | |
Set-AzureVMAccessExtension -VM $VM ` | |
-UserName $Credential.UserName ` | |
-Password $Credential.GetNetworkCredential().Password ` | |
-ReferenceName "VMAccessAgent" | | |
Update-AzureVM | |
Restart-AzureVM -ServiceName $VM.ServiceName -Name $VM.Name | |
} | |
} | |
catch { | |
Write-Error $_ | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment