Reputation: 1
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
Upvotes: 0
Views: 15579
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
Reputation: 11
I needed to grab this attribute and finally got it working:
$user = Get-AzureADUser -SearchString $displayName
$empID = $user.ExtensionProperty.employeeId
Upvotes: 1
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.
BR
Upvotes: 1
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:
Upvotes: 0