๐ฅ Recipe ยท User & Group Management
Count Total Users in a Microsoft 365 Tenant
Quickly retrieve an accurate total user count for licensing, audits, and capacity planning
Complexity
Beginner
Impact
user-management + reporting + licensing + audit
Context
Why This Matters
Knowing the total number of user accounts in your Microsoft 365 tenant is a foundational data point for license reconciliation, security audits, identity governance reviews, and capacity planning. While the number appears in several admin surfaces, getting a programmatic, repeatable count is essential for automation, reporting dashboards, and scheduled health checks.
This recipe covers three ways to get the count: the Microsoft 365 Admin Center (quickest for a one-off check), the Microsoft Graph API (best for automation), and PowerShell via the Microsoft Graph SDK (best for scripts and scheduled jobs).
When to run this
- Before a licensing renewal or true-up
- As part of a monthly tenant health report
- When reconciling HR headcount against directory accounts
- Before bulk operations that depend on knowing directory size
Expected Outcomes
After completing this recipe you will have:
- An accurate total count of user objects in the tenant (including members and guests unless filtered)
- A reusable Graph API call or PowerShell script you can embed in dashboards or scheduled reports
- Understanding of the
ConsistencyLevel: eventualheader requirement for advanced Graph queries - Optional breakdowns by user type (Member vs. Guest) and account status (enabled vs. disabled)
Risks & Considerations
Things to be aware of
- Member vs. guest users: A raw count of
/usersincludes both member accounts and B2B guest accounts. If you only want employees, filter onuserType eq 'Member'. - Disabled accounts: The default count includes disabled (blocked sign-in) accounts. Filter on
accountEnabled eq trueif you want active users only. - Licensed vs. unlicensed: The user count is NOT the same as your licensed seat count. For license usage, query
/subscribedSkusinstead. - ConsistencyLevel header: Graph's
$countendpoint and$count=truequery option require theConsistencyLevel: eventualHTTP header. Passing it as a query parameter will fail. - Permissions:
User.Read.Allis sufficient. Do not requestDirectory.Read.Allunless you need more than user data. - Deleted users: Soft-deleted users (in the recycle bin for 30 days) are not included in
/users. Query/directory/deletedItems/microsoft.graph.userif you need those.
Required Permissions
| Permission | Why It's Needed |
|---|---|
| User.Read.All | Required to enumerate and count user objects in the tenant directory |
| Directory.Read.All | Alternative permission if you also need to read related directory objects (groups, roles). Not required for a simple user count. |
The fastest way to get this done โ just ask Dex. Copy the prompt below and paste it into your Dex conversation.
For IT Admins
Paste into Dex CoAdmin