【问题标题】:Connect-AzAccount without promptConnect-AzAccount 没有提示
【发布时间】:2020-04-08 10:04:51
【问题描述】:

我正在尝试使用

登录 Azure 门户
Connect-AzAccount

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

【问题讨论】:

  • 你试过$Credential = Get-Credential; Connect-AzAccount -Credential $Credential吗?
  • 我试过但它要求提示,下面接受的答案不需要提示。谢谢!

标签: azure powershell azure-powershell


【解决方案1】:

正如乔伊所说,您可以使用不会提示的凭据登录用户帐户,请确保您的帐户未启用 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

更多详情可以参考这个SO thread

【讨论】:

  • 如果用户没有任何订阅链接会发生什么?谢谢
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2021-03-26
  • 2020-11-19
  • 2022-11-01
  • 1970-01-01
  • 2020-07-26
  • 1970-01-01
  • 2020-10-01
相关资源
最近更新 更多