Azure 无提示连接AzAccount

Azure 无提示连接AzAccount,azure,powershell,azure-powershell,Azure,Powershell,Azure Powershell,我正在尝试使用登录Azure门户 Connect-AzAccount 这段代码要求我提供一个我不需要的提示,我们可以使用一些简单的配置脚本自动登录。正如Joy所说,您可以通过凭证使用用户帐户登录,但不会出现提示,请确保您的帐户不启用MFA $User = "xxx@xxxx.onmicrosoft.com" $PWord = ConvertTo-SecureString -String "<Password>" -AsPlainText -Force $tenant = "<

我正在尝试使用登录Azure门户

Connect-AzAccount

这段代码要求我提供一个我不需要的提示,我们可以使用一些简单的配置脚本自动登录。

正如Joy所说,您可以通过凭证使用用户帐户登录,但不会出现提示,请确保您的帐户不启用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
$User=”xxx@xxxx.onmicrosoft.com"
$PWord=converttosecurestring-String'-AsPlainText-Force
$tenant=“”
$subscription=“”
$Credential=新对象-TypeName“System.Management.Automation.PSCredential”-ArgumentList$User,$PWord
连接AzaAccount-凭据$Credential-租户$Tenant-订阅$Subscription


有关更多详细信息,请参阅此项。

您是否尝试过
$Credential=Get Credential;连接AzaAccount-Credential$Credential
?我尝试过,但它要求提示,下面接受的答案不需要提示。谢谢如果用户没有任何链接到的订阅,会发生什么?谢谢