Creating script in PowerShell instead of using Azure Cli

Welcome Forums General PowerShell Q&A Creating script in PowerShell instead of using Azure Cli

This topic contains 1 reply, has 2 voices, and was last updated by

 
Participant
5 days, 3 hours ago.

  • Author
    Posts
  • #181977

    Participant
    Topics: 26
    Replies: 59
    Points: 96
    Rank: Member

    I have been able to fine Azure CLI AZ commands to use extensions to change admin password on RHEL 7 servers.
    But I would really prefer to do this with the new PowerShell AZ modules.

            az vm user update –resource-group $($vm.ResourceGroupName) –name $($vm.Name) –username $UserName –password $NewPassword
                if ( $? ) {
                    Write-Verbose -Message "Password reset for $($vm.Name). Restarting ssh!"
                    Sleep -Seconds 3
                    az vm user reset-ssh –name $($vm.Name) –resource-group $($vm.ResourceGroupName)
                }
    

    Anyone know the specifics of how to do this in Powershell without using cli2?

  • #183075

    Participant
    Topics: 0
    Replies: 8
    Points: 54
    Rank: Member

    Looks like you might be able to change the admin user password using Set-AzVMOperatingSystem -Credential. Not sure how this affects SSH credentials.

    See Set-AzVMOperatingSystem

You must be logged in to reply to this topic.