Brian Plunektt
Brian Plunektt

Reputation: 1

Get Employee ID from Azure Active Directory

I am trying to get the user name and the employee ID from Azure Active Directory, but I keep getting a can not match parameter error. See the attached image.

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

Parameter Error

Upvotes: 0

Views: 15579

Answers (4)

Santhosh Durgam
Santhosh Durgam

Reputation: 1

I have tried the below and it worked for me.

Get-AzureADUser -top 70000 | ? {$_.AccountEnabled -like $true -and $_.userType -like "Member" -and $_.ExtensionProperty.employeeId -notlike $null } |
select DisplayName,AccountEnabled,Userprincipalname,usertype,@{N="EmployeeID";E={$_.ExtensionProperty.employeeId}} 

Upvotes: 0

Amanda Whitehead
Amanda Whitehead

Reputation: 11

I needed to grab this attribute and finally got it working:

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

Upvotes: 1

Zlatan10
Zlatan10

Reputation: 15

I wasn't able to get the employeeId using AdditionalProperties.

Quickest way for me is using the azuread module, as employeeId is not a standard property but and extension, you can get that info using the following command:

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

[1]:Example https://i.sstatic.net/uAxz7.png

Also I recommend using graph API to get info from AAD.

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

BR

Upvotes: 1

Ansuman Bal
Ansuman Bal

Reputation: 11451

As there is no parameter called EmployeeId in the get-azaduser that's why it gives you the error . The employee Id is stored inside the additional properties.

So if you want to get the AD users name and employee ID you can use the below command :

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

Output:

enter image description here

Upvotes: 0

Related Questions