Hi @Suvhana
Thanks for reaching out to Microsoft Q&A forum support
I completely understand how tricky it can be to manage users across multiple verified subdomains, especially when you're trying to get a clear overview of who’s in your tenant and how they’re distributed. In most cases, if you just want to check which users exist in your tenant, a simple and effective method is to use the Microsoft Graph API endpoint
GET https://graph.microsoft.com/v1.0/auditLogs/signIns$select=userPrincipalName,createdDateTime.
This gives you basic sign-in data, including userPrincipalName, which can help identify active users. However, this method doesn’t support filtering by ___domain directly on the server side, and with a large tenant, manually processing this data can be time-consuming and inefficient.
After doing some research, I found that if you want to list users based on specific subdomains (like @sub1.___domain.com or @sub2.___domain.com), you’ll need to use a more advanced query such as
GET https://graph.microsoft.com/v1.0/users$count=true&$filter=endsWith(mail,'@subdomain.___domain.com').
This is part of Microsoft Graph’s Advanced Query Capabilities, which allow for more powerful filtering options like startsWith
, endsWith
. However, there are a few important requirements: you must include the header ConsistencyLevel: eventual
, and you need to append &$count=true
to the query string. It’s also worth noting that these advanced filters are only supported on certain endpoints like /users
, and not on /auditLogs/signIns
.
At the moment, we don’t have the right environment or permissions to test this advanced query setup ourselves. That said, I’ve found some helpful resources that might guide you further.
Link Article: Advanced query capabilities on Microsoft Entra ID objects - Microsoft Graph | Microsoft Learn
Additionally, I came across a GitHub issue that discusses potential bugs and limitations when using these advanced queries with the Microsoft Graph PowerShell SDK it might be worth reviewing if you run into unexpected behavior.
Note: Microsoft is providing this information as a convenience to you. The sites are not controlled by Microsoft. Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. Please make sure that you completely understand the risk before retrieving any suggestions from the above link
Hope you will solve the problem soon
If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread