简体   繁体   English

Connect-AzAccount 没有提示

[英]Connect-AzAccount without prompt

I am trying to login into Azure Portal by using我正在尝试使用登录到 Azure 门户

Connect-AzAccount

This code asks me for a prompt which I don't want, can we Auto login by using some simple config script.这段代码要求我提供一个我不想要的提示,我们可以使用一些简单的配置脚本自动登录吗?

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.正如乔伊所说,您可以使用不会提示的凭据登录用户帐户,请确保您的帐户未启用 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 .有关更多详细信息,您可以参考此SO 线程

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM