Is it possible to query Azure Active Directory users based on last modified date?

Viewed 684

I need to get a users from Azure Active directory who were created/modified since a specific date. Is this possible, via graph or any other means?

I have checked the graph api documentation but cannot see a lastModified filter.

2 Answers

There is no such property called lastModifiedDateTime in Microsoft Graph.

As @Tiny Wang suggested, you can query using createdDateTime.

From Azure CLI, to get Azure AD users created since a specific date, make use of below command:

az ad user list --filter "createdDateTime ge datetime'yyyy-MM-ddTHH:mm:ssZ'"

From Microsoft Graph API, to get Azure AD users created since a specific date, make use of below command:

https://graph.microsoft.com/beta/users?$filter=createdDateTime ge yyyy-MM-ddTHH:mm:ssZ &$select=displayName,createdDateTime,id

enter image description here

Before using the above command, make sure to give the below permissions:

enter image description here

References:

How to get list of recently created AD users from azure active directory using Azure CLI - Stack Overflow

Microsoft Graph User last modified field - Stack Overflow

Get a user - Microsoft Graph beta | Microsoft Docs

As mentioned in the comment there is no modifiedDateTime or similar property on User resource type.

If you want to filter users who were created since a specific date then you can use createdDateTime property.

Example to get users created since 01/01/2022

GET /users?$filter=createdDateTime ge 2022-01-01T00:00:00Z

Example to get users created in 2021

GET /users?$filter=(createdDateTime ge 2021-01-01T00:00:00Z AND createdDateTime le 2021-12-31T23:59:59Z)
Related