How to Get Azure AD Users Updated in the Last 24 Hours with PowerShell
Question details
The user wants to retrieve a list of Azure Active Directory users whose directory information was changed or synced within the past 24 hours.
- Product
- PowerShell
- Device & OS
- not provided
- Scenario
- Running an administrative PowerShell script to audit or track recent directory updates for Azure AD users.
- Observed behavior
- The initial query based on the LastDirSyncTime property fails or returns empty results because the required AzureAD PowerShell module is not installed or not actively authenticated.
Ensure you have the necessary administrative privileges in your Azure Active Directory tenant and that you are running PowerShell with elevated permissions (Run as Administrator).
Install the AzureAD Module and Authenticate
To successfully query Azure AD properties like LastDirSyncTime, you must install the official AzureAD module and establish an active session.
PowerShell requires the AzureAD module to interact with your directory tenant. Without an authenticated session, directory properties cannot be retrieved.
Right-click the Windows Start menu button and select Windows PowerShell (Admin) or Windows Terminal (Admin) to open the console with elevated privileges.
Type the command 'Install-Module -Name AzureAD' and press Enter. If prompted to install from an untrusted repository (PSGallery), type 'Y' and press Enter to confirm.
Run the command 'Connect-AzureAD'. A Microsoft sign-in window will pop up. Enter your Azure administrator credentials to authenticate your session.
Execute your PowerShell script using the 'Get-AzureADUser' cmdlet, filtering the results by the 'LastDirSyncTime' property to find users updated within the last 24 hours.

Analyze Your Exported Azure Reports with WPS Office
After using PowerShell to export your Azure AD user reports to a CSV file, use WPS Office to easily view, filter, and analyze the data. WPS Office is a lightweight, free alternative to Microsoft Office that handles large spreadsheets smoothly.
- 1. Download and Install WPS Office: Visit the official WPS website to download the free office suite and install it on your workstation.
- 2. Export Azure Data to CSV: In your PowerShell script, pipe the user query results to the 'Export-Csv' cmdlet to generate a report file.
- 3. Analyze in WPS Spreadsheet: Open the generated CSV file in WPS Spreadsheet to apply filters, highlight recent changes, and format your auditing report.

Frequently Asked Questions
Why is the LastDirSyncTime property blank for some Azure AD users?
This property typically records the last time a user was synchronized from an on-premises Active Directory via Azure AD Connect. If the user is a cloud-only account and has never been synced from on-premises, this property may remain blank.
Do I need Global Administrator rights to run this PowerShell query?
No, you do not strictly need Global Administrator rights. However, you must have an administrative role with sufficient read permissions for the directory, such as Directory Readers or User Administrator, to query user details.
How can I export my PowerShell query results to view in a spreadsheet?
You can append the Export-Csv command to your PowerShell query. For example: 'Get-AzureADUser ... | Export-Csv -Path C:\Users\Report.csv -NoTypeInformation'. You can then open this file in spreadsheet software like WPS Office.




