powershell - 添加-AzureAccount : user_realm_discovery_failed: User realm discovery failed: Unable to connect to the remote

标签 powershell azure

我有一个英雄 PowerShell 脚本,它尝试连接到 Azure:

$username = "asdfasdf"
$password = "asdfasdf"
$secstr = New-Object -TypeName System.Security.SecureString
$password.ToCharArray() | ForEach-Object {$secstr.AppendChar($_)}
$cred = new-object -typename System.Management.Automation.PSCredential -argumentlist $username, $secstr
Add-AzureAccount -Credential $cred
Select-AzureSubscription -SubscriptionId asdfasdf

但我收到此错误:

Add-AzureAccount : user_realm_discovery_failed: User realm discovery failed: Unable to connect to the remote 
server
At line:6 char:1
+ Add-AzureAccount -Credential $cred
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : CloseError: (:) [Add-AzureAccount], AadAuthenticationFailedException
    + FullyQualifiedErrorId : Microsoft.WindowsAzure.Commands.Profile.AddAzureAccount

我的用户绝对是 Azure 目录的共同管理员。我是否必须使用代理才能与 Azure 通信?

最佳答案

嗯,由于多种原因,这似乎是一个常见错误。尝试连接到服务结构时,我的用户名格式错误并收到错误:

user_realm_discovery_failed: User realm discovery failed

somedomain\fred应该是<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="9ff9edfafbdfecf0f2fafbf0f2fef6f1b1fcf0f2" rel="noreferrer noopener nofollow">[email protected]</a> .

一旦我纠正它,它就工作得很好。因此,鉴于上述答案,此错误似乎是由于连接或身份验证问题而出现的。

关于powershell - 添加-AzureAccount : user_realm_discovery_failed: User realm discovery failed: Unable to connect to the remote,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41572583/

相关文章:

windows - Powershell 设置盖子关闭 Action

powershell - 我可以在 Windows Powershell ISE 中使用 "break when an exception is thrown"吗?

azure - 有关 Web 应用程序中存储帐户的澄清

azure - 如何在服务器端运行 WebGL 和 JavaScript?

powershell - 无法使用 Import-Csv 导入 CSV 文件

windows - 使用 Powershell 创建的本地用户帐户未显示在设置 "Family & Other people"中

arrays - Powershell:作为函数参数的 PSCustomObject 数组意外更改

azure - 使用 Azure 逻辑应用访问始终加密的数据

azure - 通过 Azure Active Directory 进行 Windows 表单例份验证

azure - 在 Salesforce APEX 中实现 Azure Put Blob