2017-09-04 90 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