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

Announcements

News and Announcements icon
Community site session details

Community site session details

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

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

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Valantis Profile Picture

Valantis 427

#2
Vish WR Profile Picture

Vish WR 316

#3
David_MA Profile Picture

David_MA 260 Super User 2026 Season 1

Last 30 days Overall leaderboard