2017-09-04 110 views
0

如何檢索employeeid屬性?我執行時沒有得到任何輸出:如何檢索employeeid屬性

Get-AzureADUser -ObjectId "[email protected]" | 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 "[email protected]" | 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

它的字典/哈希表是一個鍵/值對的對象,所以嘗試:

(Get-AzureADUser -ObjectId "[email protected]").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 
+0

謝謝我編輯了我的問題ñ。我如何在最新的更新腳本中添加這個散列表? – Arbelac

+0

最後你能看到我的其他問題嗎? https://stackoverflow.com/questions/46035299/azure-active-directory-v2-powershell-finding-all-licenced-office-365-users再次感謝 – Arbelac