Skip to content

Instantly share code, notes, and snippets.

@rchaganti
Created August 13, 2014 16:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rchaganti/bf5b33edb6813b52cc3b to your computer and use it in GitHub Desktop.
Save rchaganti/bf5b33edb6813b52cc3b to your computer and use it in GitHub Desktop.
Reset-AzureVMUserPassword
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