Others

How to Get Azure AD Users Updated in the Last 24 Hours with PowerShell

Amos GikundaAmos Gikunda Nov 3, 2026 869 views

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.
Before you start

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).

Solution 1Recommended

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.

1
Open PowerShell as Administrator

Right-click the Windows Start menu button and select Windows PowerShell (Admin) or Windows Terminal (Admin) to open the console with elevated privileges.

2
Install the AzureAD Module

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.

3
Connect to Azure AD

Run the command 'Connect-AzureAD'. A Microsoft sign-in window will pop up. Enter your Azure administrator credentials to authenticate your session.

4
Run the User Query

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.

Install the AzureAD Module and Authenticate
Community Support: If the command still does not return the expected results, verify that the LastDirSyncTime property is actively updating in your hybrid environment. You can also seek assistance in the Microsoft Q&A Azure Active Directory community.
Free Microsoft Office alternative

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. 1. Download and Install WPS Office: Visit the official WPS website to download the free office suite and install it on your workstation.
  2. 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. 3. Analyze in WPS Spreadsheet: Open the generated CSV file in WPS Spreadsheet to apply filters, highlight recent changes, and format your auditing report.
Fully compatible with Microsoft Excel (.xlsx, .csv) formats for seamless data analysis.Lightweight architecture ensures that large PowerShell data exports load instantly without system lag.Familiar user interface requires no learning curve, allowing you to filter directory logs immediately.
microsoft office alternative - wps office

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.