【问题标题】:Get Employee ID from Azure Active Directory从 Azure Active Directory 获取员工 ID
【发布时间】:2022-06-16 01:00:42
【问题描述】:

我正在尝试从 Azure Active Directory 获取用户名和员工 ID,但我不断收到无法匹配参数错误。见附图。

Get-AzADUser -UserPrincipalName $.UserPrincipalName -EmployeeID $.EmployeeID

Parameter Error

【问题讨论】:

  • 如果回答对您有帮助,请Accept it as an Answer,以便遇到相同问题的其他人可以找到此解决方案并解决他们的问题。

标签: azure azure-active-directory


【解决方案1】:

由于在 get-azaduser 中没有名为 EmployeeId 的参数,这就是它给您错误的原因。员工 ID 存储在附加属性中。

因此,如果您想获取 AD 用户名和员工 ID,可以使用以下命令:

Get-AzADUser | Select-Object UserprincipalName , @{N="EmployeeId";E={$_.AdditionalProperties["employeeId"]} }

输出:

【讨论】:

  • 这很有用,只是它不输出员工 ID。我会用老式的方式来做,一张一张地看每张唱片。谢谢
【解决方案2】:

我无法使用 AdditionalProperties 获取 employeeId。

对我来说最快的方法是使用 azuread 模块,因为employeeId 不是标准属性而是扩展,您可以使用以下命令获取该信息:

get-azureaduser -objectid user@domain | get-azureaduserextension

[1]:示例https://i.stack.imgur.com/uAxz7.png

我还建议使用图形 API 从 AAD 获取信息。

https://devblogs.microsoft.com/premier-developer/getting-started-with-graph-api-and-graph-explorer/?msclkid=249a6a28ae7311ec958ae49c7dc811e2

BR

【讨论】:

  • 这很有用,它提供了一个,但总比没有好。我会用老式的方式来做,一张一张地看每张唱片。谢谢
【解决方案3】:

我需要抓住这个属性,终于让它工作了:

$user = Get-AzureADUser -SearchString $displayName
$empID = $user.ExtensionProperty.employeeId

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-06-26
    • 2018-02-17
    • 1970-01-01
    相关资源
    最近更新 更多