PowerShell Script – Get Creation Date Of All Azure AD Users

This article will show you how to get the creation date of all your Azure Active Directory users using a PowerShell script. This is important for auditing purposes and can be used in other scripts to remove any users that were created after a certain date.

CreatedDate Azure AD Users

The script is using the AzureADPreview module. You can install the module using this post. The script needs to run on a Windows machine with PowerShell 5.1. For more information about all the Azure AD modules read this post.

$DataArray = @()
$ADUsers = get-azureaduser -all:$true
foreach($User in $ADUsers)
    $Creation = Get-AzureADUserExtension -objectid $user.UserPrincipalName
    $UserUPN = $user.UserPrincipalName
    $UserDisplayName = $User.DisplayName

   $TableRow = "" | select CreationDate, UserPrincipalName, DisplayName
   $TableRow.CreationDate = $Creation.createdDateTime
   $TableRow.UserPrincipalName = $UserUPN 
   $TableRow.DisplayName = $UserDisplayName
   $DataArray += $TableRow


$DataArray | format-table

More about the script

The script will use get-azureaduser cmdlet to get all the users and the get-AzureAdUserExtention to find the creation date and time. The script also creates a data array to store all the details and create a table for printing the result.

About Azure Active Directory

Azure Active Directory is a cloud-based directory and identity management service. The service manages user and group accounts and provides insights about those accounts, such as their location. It also helps with security features like multifactor authentication. This service is built on the Microsoft Identity platform and is as federated as they come. A federated Azure AD can be integrated into other federated systems with SSO capabilities that customers may have in place already.

To learn more about Azure Active Directory, please visit the category page.