问题
I am trying to login into Azure Portal by using
Connect-AzAccount
This code asks me for a prompt which I don't want, can we Auto login by using some simple config script.
回答1:
As Joy said, you could login with the user account by credential which will no prompt, make sure your account doesn't enable the MFA.
$User = "xxx@xxxx.onmicrosoft.com"
$PWord = ConvertTo-SecureString -String "<Password>" -AsPlainText -Force
$tenant = "<tenant id>"
$subscription = "<subscription id>"
$Credential = New-Object -TypeName "System.Management.Automation.PSCredential" -ArgumentList $User,$PWord
Connect-AzAccount -Credential $Credential -Tenant $tenant -Subscription $subscription
For more details, you could refer to this SO thread.
来源:https://stackoverflow.com/questions/61098097/connect-azaccount-without-prompt