简体   繁体   中英

unable to list the properties of azure ad user (createddatetime)

I have many users in my Azure AD tenant, I want to collect the data of the users when they are created.

I am able to get the user details by running Get-AzureADUser . So, I just modified the command as

Get-AzureADUser | Select-Object, Mail, createdDateTime

But this returned details but the createdDateTime field was empty. After some research I found that createdDateTime is an extension attribute .

I found this command Get-AzureADUserExtension but now my question is I want to get the list of users with their email and the created date time.

Any script to achieve my scenario?

TIA

I am not using the Az Module as its end-of-life is not that far away anymore. It got replaced by the mgGraph cmdlets (install-module microsoft.graph).

There I can do:

get-mguser -Filter "userPrincipalName eq 'myName@myCompany.com'" -Property CreatedDateTime,Mail,UserPrincipalName

The property CreatedDateTime does not need to be expanded but it must be explicitly listed as property to retrieve, otherwise I won't get the value. I think you can do simliar with the Az cmdlets or otherwise switch to the MgGraph cmdlets which you have to do anyways until 2024.

I tried to reproduce the same in my environment and got the results successfully like below:

To get the createdDateTime of Azure AD Users with email address, I tried the below script:

$result = @()
$AAD_users = Get-AzureADUser -All:$true
foreach ($AAD_User in $AAD_users) {
$info = [PSCustomObject]@{
Email     = $AAD_User.mail
CreationDateTime  = (Get-AzureADUserExtension -ObjectId $AAD_User.ObjectId).Get_Item("createdDateTime")
}
$result+= $info
}
$result

I am able to get the list of users with createdDateTime successfully like below:

在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM