powershellazure-active-directoryazure-ad-b2b

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


Solution

  • 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:

    enter image description here