Connect-AzAccount without prompt

北城余情 提交于 2021-01-28 19:01:45

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!