gpt4 book ai didi

azure - Powershell Connect-AzureAD 错误 "accessing_ws_metadata_exchange_failed"

转载 作者:行者123 更新时间:2023-12-02 22:14:21 25 4
gpt4 key购买 nike

我正在编写一个 Powershell 脚本,需要使用代码连接到 Azure Active Directory。

如果我通过提示连接,它工作正常,但使用代码(在代码中提供用户 ID 和密码)会引发以下错误:

Connect-AzureAD : One or more errors occurred.: accessing_ws_metadata_exchange_failed: Accessing WS metadata exchange failed At C:\Users\yawer.iqbal\Desktop\Untitled3.ps1:8 char:3 + Connect-AzureAD -Credential $Credential -TenantID $tenant

这是我的代码:

$User = "<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="3f5246565b7f504a4b53505054115c5052" rel="noreferrer noopener nofollow">[email protected]</a>"
$PWord = ConvertTo-SecureString -String "*******" -AsPlainText -Force
$tenant = "bingu12outlook.onmicrosoft.com"
$Credential = New-Object -TypeName "System.Management.Automation.PSCredential" -ArgumentList $User, $PWord
Import-Module AzureAD
Connect-AzureAD -Credential $Credential -TenantID $tenant

我尝试过:添加此行但它也不起作用:

[System.Net.WebRequest]::DefaultWebProxy.Credentials = [System.Net.CredentialCache]::DefaultCredentials

请帮忙

最佳答案

不确定是什么原因导致了问题,如果可以接受,您可以使用工作帐户来执行此操作,在我这边工作正常。

首先,导航至 Azure Active Directory在 azure 门户中 -> Users -> New user ,请参阅此 link 。然后您将获得一个工作帐户,例如 <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="2b5353536b4942454c5e1a19445e5f47444440054445464248594458444d5f05484446" rel="noreferrer noopener nofollow">[email protected]</a> ,首次登录时记得重置密码。

我的具体测试命令:

$User = "<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="c7ada8bebfbf87bfbfbfbfe9a8a9aaaea4b5a8b4a8a1b3e9a4a8aa" rel="noreferrer noopener nofollow">[email protected]</a>"
$PWord = ConvertTo-SecureString -String "xxxxxxx" -AsPlainText -Force
$tenant = "xxxx.onmicrosoft.com"
$Credential = New-Object -TypeName "System.Management.Automation.PSCredential" -ArgumentList $User,$PWord
Connect-AzureAD -Credential $Credential -TenantID $tenant

enter image description here

关于azure - Powershell Connect-AzureAD 错误 "accessing_ws_metadata_exchange_failed",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54582897/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com