【问题标题】:Add-AzureAccount -credential not working as I'd hopedAdd-AzureAccount -credential 没有像我希望的那样工作
【发布时间】:2016-01-05 19:47:20
【问题描述】:

4 天前(2014 年 8 月 4 日)发布了 Azure Powershell 的新版本,其中在 Add-AzureAccount cmdlet 中包含了一个新的 -Credential 参数。我正在尝试使用它,但我显然做错了什么。 首先,我将密码存储在一个文件中:

read-host -assecurestring | convertfrom-securestring | out-file C:\temp\securestring.txt

然后尝试在 Add-AzureAccount 中使用它

$password = cat C:\temp\securestring.txt | convertto-securestring
$username = "dhdom1\jamiet" #yes, this is the correct username
$mycred = new-object -typename System.Management.Automation.PSCredential -argumentlist $username,$password
Add-AzureAccount -credential $mycred

调用 Add-AzureAccount 失败:

Add-AzureAccount : user_realm_discovery_failed: 用户领域发现 失败:远程服务器返回错误:(404) Not Found。

我知道“dhdom1\jamiet”是正确的帐户。任何人都知道为什么这可能会失败? TIA

【问题讨论】:

  • 虽然我一直坚持让这个在本地工作,但很想知道您是如何将上述内容改编为自动化运行手册或功能应用程序的?

标签: powershell azure


【解决方案1】:

您应该使用用于登录 Azure 门户的组织帐户。因此,它可能看起来像 jamiet@yourorganizationalaccountname.com 或类似的东西。

【讨论】:

  • 请注意,-Credential 参数目前不支持 Microsoft 帐户。它必须是组织帐户。如果您没有将组织 Active Directory 链接到您的 Azure AD,您仍然可以创建一个 Azure AD 用户,使其成为共同管理员并使用它。默认情况下,每个 Azure 订阅都有一个 Azure AD。
  • 我尝试使用我的组织帐户,但它给了我这个错误:Add-AzureAccount:sso.organizationalaccountname.com/adfs/services/trust/13/… 的联合服务返回错误:ID3242:无法验证或授权安全令牌。:远程服务器返回错误:(500) 内部服务器错误。有什么建议吗?
【解决方案2】:
  1. 打开 azure powershell 窗口
  2. 输入 Add-AzureAccount 然后输入
  3. 将向他弹出一个登录屏幕,然后输入此凭据外观
  4. 由此,此凭据存储在此 PowerShell 窗口中,然后从此特定窗口运行所有其他脚本。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-12-30
    • 2016-12-03
    • 2021-10-06
    • 1970-01-01
    • 2019-12-04
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多