Skip to content

Instantly share code, notes, and snippets.

@ploegert
Created June 8, 2015 19:20
Show Gist options
  • Select an option

  • Save ploegert/7000ca8a4eb21f88b866 to your computer and use it in GitHub Desktop.

Select an option

Save ploegert/7000ca8a4eb21f88b866 to your computer and use it in GitHub Desktop.
Reset Azure VM User Password
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