没有提示的Connect-AzAccount [英] Connect-AzAccount without prompt

查看:49
本文介绍了没有提示的Connect-AzAccount的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用

Connect-AzAccount

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

This code asks me for a prompt which I don't want, can we Auto login by using some simple config script.

推荐答案

正如Joy所说,您可以通过凭据登录用户帐户,而不会提示您,请确保您的帐户未启用MFA.

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

有关更多详细信息,您可以参考此 SO线程.

For more details, you could refer to this SO thread.

这篇关于没有提示的Connect-AzAccount的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆