web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Get user count - Graph...
Power Automate
Unanswered

Get user count - Graph API

(0) ShareShare
ReportReport
Posted on by 340

Hi guys,

 

So I am trying to get a user count for multiple tenants so thought I would run a Graph API query.

I have created the app registration in the target tenants and then running the following in flow:

da1ve_0-1658810237208.png

This is working fine but the problem is I cant differentiate between current and old users. I have set the header to check for accounts that are enabled. This returns active users, archived users (shared mailboxes) as well as guest users. I tried to filter by active domain name using:

https://graph.microsoft.com/v1.0/users?$count=true&$filter=endsWith(mail,'@domain.com')

But that returns 

{
 "error": {
 "code": "Request_UnsupportedQuery",
 "message": "Unsupported Query.",
 "innerError": {

According to this MS doc, this should be supported (https://docs.microsoft.com/en-us/graph/query-parameters#filter-parameter)

da1ve_1-1658810466841.png

Any idea where this is going wrong or perhaps you know of a better way to count active users?

 

Thanks,
David

Categories:
I have the same question (0)
  • Verified answer
    Adam-Symplifier Profile Picture
    51 on at

    You need to add a consistency level header, this function works:

    https://graph.microsoft.com/v1.0/users?$count=true&ConsistencyLevel=eventual&$filter=endsWith(mail,'@domain.com')

     

    Also FYI the Graph Explorer is great for repeat testing of API calls https://developer.microsoft.com/en-us/graph/graph-explorer

     

    If this resolves your query please mark this as a solution.

  • da1ve Profile Picture
    340 on at

    Perfect - thank you @Adam-Symplifier 

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 538 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 405 Moderator

#3
abm abm Profile Picture

abm abm 252 Most Valuable Professional

Last 30 days Overall leaderboard