azure - Connect-AzAccount 无提示

标签 azure powershell azure-powershell

我正在尝试使用

登录 Azure 门户
Connect-AzAccount

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

最佳答案

正如Joy所说,您可以通过凭据使用用户帐户登录,但不会出现任何提示,请确保您的帐户没有启用MFA。

$User = "<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="4038383800383838386e2f2e2d2923322f332f26346e232f2d" rel="noreferrer noopener nofollow">[email protected]</a>"
$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

enter image description here

更多详情可以引用这个SO thread .

关于azure - Connect-AzAccount 无提示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61098097/

相关文章:

powershell - 在 .NetCore 应用程序中运行 PS 时出错 - 无法执行操作,因为运行空间不在 'Opened' 状态。运行空间的当前状态是 'Broken'

powershell - 从 IIS 绑定(bind)中检索主机名值

azure - 无法授予 C :/directory for user in Azure pipeline (provisioning machine - vs2017-win2016) 写入权限

通过powershell进行Azure模板部署: "Template parameter JToken type is not valid"

azure - TransactionScope 和 Azure 表存储

azure - 将安全组声明添加到自定义 Azure Active Directory 应用程序的 SAML token

powershell - PowerShell-如果行包含字符串,请在开头插入一些字符

azure - 创建 Azure 存储 Blob 容器时出现错误 403(启用存储防火墙

azure - kubernetes 500 内部服务器故障排除

azure - 如何从 Web 应用程序内的容器访问 Azure VM 的私有(private) IP 地址(两个资源位于同一 VNet 上)?