与组织帐户的Login-AzureRMAccount非交互式失败

时间:2018-07-05 09:55:47

标签: powershell azure azure-active-directory azure-automation

我能够使用弹出窗口登录Login-AzureRmAccount。我需要在VSTS CI主机中使用非交互模式。当我尝试在计算机上执行以下操作时:

$username = "my org login"
$pass = ConvertTo-SecureString "Mypass" -AsPlainText -Force
$cred = New-Object PSCredential($username,$pass)
Login-AzureRmAccount -Credential $cred

我收到消息:

Login-AzureRmAccount : accessing_ws_metadata_exchange_failed: Accessing WS 
metadata exchange failed: The underlying con
nection was closed: An unexpected error occurred on a send.
At line:1 char:1
+ Login-AzureRmAccount -Credential $cred
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : CloseError: (:) [Connect-AzureRmAccount], 
AadAuthenticationFailedException
+ FullyQualifiedErrorId : 
Microsoft.Azure.Commands.Profile.ConnectAzureRmAccountCommand

我没主意了。

1 个答案:

答案 0 :(得分:1)

您不能对启用了MFA的帐户使用静默身份验证。您必须走其他路线。