如何检索employeeid属性

时间:2017-09-04 09:49:31

标签: powershell azure-active-directory

如何检索employeeid属性?执行时我没有得到任何输出:

Get-AzureADUser -ObjectId "Andre@contoso.com" | Select-Object -ExpandProperty ExtensionProperty

Key                         Value
---                         -----
odata.metadata              https://graph.windows.net/xxxxxxxxxxx-xxxx-xxxxxxxxxxxx/$metadata#directoryObjects/Mic...
odata.type                  Microsoft.DirectoryServices.User
employeeId                  118880
onPremisesDistinguishedName
userIdentities              []

我不知道如何使用AzureAD PowerShell检索它。

Get-AzureADUser -ObjectId "Andre@contoso.com" | Select-Object employeeId

employeeId
----------

上次更新:

$_default_log = $env:userprofile + '\Documents\azuread_enabled_accounts.csv'
Get-AzureADUser -All $true -Filter 'accountEnabled eq true' |
    select DisplayName, UserPrincipalName, Mail, Department, UserType,
        CreationType, RefreshTokensValidFromDateTime, AccountEnabled,
        @{name='Licensed';expression={if($_.AssignedLicenses){$TRUE}else{$False}}},
        @{name='Plan';expression={if($_.AssignedPlans){$TRUE}else{$False}}},ObjectId |
    Export-Csv $_default_log -NoTypeInformation -Encoding UTF8

1 个答案:

答案 0 :(得分:1)

它的字典/ HashTable是一个键/值对象,所以试试:

(Get-AzureADUser -ObjectId "Andre@contoso.com").ExtensionProperty["employeeId"]

使用您的示例,添加为最后一个属性:

$_default_log = $env:userprofile + '\Documents\azuread_enabled_accounts.csv'
get-azureaduser -all $true -filter 'accountEnabled eq true' | select DisplayName,`
UserPrincipalName,Mail,Department,UserType,CreationType,RefreshTokensValidFromDateTime,AccountEnabled,`
@{name='Licensed';expression={if($_.AssignedLicenses){$TRUE}else{$False}}},`
@{name='Plan';expression={if($_.AssignedPlans){$TRUE}else{$False}}},ObjectId, `
@{N="EmployeeId";E={$_.ExtensionProperty["employeeId"]} } | export-csv $_default_log -NoTypeInformation -Encoding UTF8