Azure Powershell抛出"未知用户类型"

tra*_*max 8 powershell azure azure-powershell

我正在尝试针对AD帐户验证Powershell脚本(根据本指南):

$userName = "username@mydomain.com"
$securePassword = ConvertTo-SecureString -String "myPassword1" -AsPlainText -Force
$cred = New-Object System.Management.Automation.PSCredential($userName, $securePassword)
Add-AzureAccount -Credential $cred
Run Code Online (Sandbox Code Playgroud)

但是我收到错误:

Add-AzureAccount : unknown_user_type: Unknown User Type
At line:2 char:1
+ Add-AzureAccount -Credential $cred
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : CloseError: (:) [Add-AzureAccount], AadAuthenticationFailedException
    + FullyQualifiedErrorId : Microsoft.WindowsAzure.Commands.Profile.AddAzureAccount
Run Code Online (Sandbox Code Playgroud)

我输入用户名/密码并不重要,即使是"adsfasdf",用户名和密码都会给我相同的结果.

以前有人修过这个问题吗?

Ama*_*rma 1

对于任何提出这个问题的人,我提供的分析解决了我的环境中的类似问题。我还在考虑以下回复中原始问题中非常有用的评论。

  1. 请检查您是否能够使用这些凭据并手动登录Azure 门户
  2. 确保您使用的帐户是组织帐户。Microsoft 有安全限制,您无法使用用于各种目的和网站的 Microsoft 帐户(以前称为 live id)登录。此组织帐户必须与 Microsoft 帐户分开。

在 Microsoft 官方发布的文档中阅读有关组织帐户要求的更多信息:Windows Azure 组织帐户常见问题解答