我可以使用以下命令连接到 AzureAD 并针对 AD 运行查询
Connect-AzureAD -Confirm
但是,当我尝试使用 Get-Credential 并将其存储为变量时,它似乎不起作用,不知道为什么我收到不支持的用户类型“Unkown”
> $Credential = Get-Credential
cmdlet Get-Credential at command pipeline position 1
Supply values for the following parameters:
Credential
> Connect-AzureAD -Credential $Credential
WARNING: Install the latest PowerShell module, the Microsoft Graph PowerShell SDK, for new features and improvements!
https://aka.ms/graphPSmigration
Connect-AzureAD : One or more errors occurred.
At line:1 char:1
+ Connect-AzureAD -Credential $Credential
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : AuthenticationError: (:) [Connect-AzureAD], AggregateException
+ FullyQualifiedErrorId : Connect-AzureAD,Microsoft.Open.Azure.AD.CommonLibrary.ConnectAzureAD
Connect-AzureAD : Unsupported User Type 'Unknown'. Please see https://aka.ms/msal-net-up.
At line:1 char:1
+ Connect-AzureAD -Credential $Credential
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : AuthenticationError: (:) [Connect-AzureAD], MsalClientException
+ FullyQualifiedErrorId : Connect-AzureAD,Microsoft.Open.Azure.AD.CommonLibrary.ConnectAzureAD
Connect-AzureAD : One or more errors occurred.
At line:1 char:1
+ Connect-AzureAD -Credential $Credential
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Connect-AzureAD], AggregateException
+ FullyQualifiedErrorId : System.AggregateException,Microsoft.Open.Azure.AD.CommonLibrary.ConnectAzureAD
尝试使用 PowerShell 连接到 AzureAD,但凭据未知。
感谢
jdweng
提出同样的观点。
当您传递本地
VM
凭据以连接到 Azure AD
时,会遇到上述错误。 Azure AD 需要用户 UPN 和 密码,因为它需要域名才能连接到 Azure AD
。
当我传递正确的
Azure AD UPN
和 password
而不是本地用户名时,它会连接到 Azure AD
并能够获取用户详细信息。
Install-Module AzureAD
$Credential = Get-Credential
Connect-AzureAD -Credential $Credential
Get-AzureADUser -Top 10