--- title: "Count Total Users in a Microsoft 365 Tenant" slug: "dex-wf-count-total-users" updated: 2026-11-30T16:16:18Z published: 2026-11-30T16:16:18Z canonical: "documentation.sysaid.com/dex-wf-count-total-users" --- > ## Documentation Index > Fetch the complete documentation index at: https://documentation.sysaid.com/llms.txt > Use this file to discover all available pages before exploring further. # Count Total Users in a Microsoft 365 Tenant Retrieve an accurate total user count for licensing, audits, and capacity planning. **Complexity:** Beginner. **Impact:** user-management + reporting + licensing + audit. ## Why use this workflow 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, a programmatic, repeatable count is essential for automation, reporting dashboards, and scheduled health checks. This workflow covers three ways to get the count: the Microsoft 365 admin center (best for a one-off check), the Microsoft Graph API (best for automation), and PowerShell with 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 - 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: eventual` header requirement for advanced Graph queries - Optional breakdowns by user type (Member vs. Guest) and account status (enabled vs. disabled) ## Risks and considerations ### Things to be aware of - **Member vs. guest users:** A raw count of `/users` includes both member accounts and B2B guest accounts. If you only want employees, filter on `userType eq 'Member'`. - **Disabled accounts:** The default count includes disabled (blocked sign-in) accounts. Filter on `accountEnabled eq true` if you want active users only. - **Licensed vs. unlicensed:** The user count is not the same as your licensed seat count. For license usage, query `/subscribedSkus` instead. - **ConsistencyLevel header:** The Graph `$count` endpoint and the `$count=true` query option require the `ConsistencyLevel: eventual` HTTP header. Passing it as a query parameter fails. - **Permissions:** `User.Read.All` is sufficient. Do not request `Directory.Read.All` unless you need more than user data. - **Deleted users:** Soft-deleted users are not included in `/users`. Query `/directory/deletedItems/microsoft.graph.user` if 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. | ## Ask Dex Paste the prompt into a Dex conversation. ### Prompt for IT admins ``` How many users are in our Microsoft 365 tenant? Give me the total plus a breakdown of members vs. guests and enabled vs. disabled accounts. ``` ## Manual steps (admin center) ### Microsoft 365 admin center 1. Sign in to the [Microsoft 365 admin center](https://admin.microsoft.com) as a Global Reader or higher. 2. In the left navigation, go to **Users** > **Active users**. 3. Read the total count shown at the top of the Active users list. 4. To include blocked (disabled) accounts, use the **Filter** dropdown and select *All users*. 5. For guest user counts, go to **Users** > **Guest users**. 6. For a breakdown with exportable data, go to **Reports** > **Usage** > **Microsoft 365 usage** and select the *Active users* report. ### Microsoft Entra admin center (alternative) 1. Sign in to the [Microsoft Entra admin center](https://entra.microsoft.com). 2. Go to **Identity** > **Users** > **All users**. 3. Read the total count shown at the top of the list. Use the filter bar to scope by user type, creation date, or sign-in activity. 4. Select **Download users** to export a CSV for offline analysis. ## Microsoft Graph API Graph exposes a dedicated `$count` endpoint that returns an integer. It requires the `ConsistencyLevel: eventual` HTTP header. ### Simple total count ``` GET https://graph.microsoft.com/v1.0/users/$count ConsistencyLevel: eventual ``` **Response:** a plain integer in the response body. ### Count only member users (exclude guests) ``` GET https://graph.microsoft.com/v1.0/users/$count?$filter=userType eq 'Member' ConsistencyLevel: eventual ``` ### Count only enabled users ``` GET https://graph.microsoft.com/v1.0/users/$count?$filter=accountEnabled eq true ConsistencyLevel: eventual ``` ### Count with an inline page (count plus a sample) ``` GET https://graph.microsoft.com/v1.0/users?$count=true&$top=1&$select=id,displayName,userType ConsistencyLevel: eventual ``` The response includes an `@odata.count` property with the total, plus the first user as a sample: ``` {  "@odata.count": {total},  "value": [    { "id": "...", "displayName": "...", "userType": "Member" }  ] } ``` ### Common pitfall Passing `ConsistencyLevel` as a query string (`?ConsistencyLevel=eventual`) fails with a 400 error. It must be an HTTP header. ## PowerShell The `Microsoft.Graph.Users` module wraps the Graph endpoints and sends the `ConsistencyLevel` header when you pass `-ConsistencyLevel eventual`. ### Install the module (first time only) ``` Install-Module Microsoft.Graph.Users -Scope CurrentUser ``` ### Connect and get the count ``` Connect-MgGraph -Scopes "User.Read.All" # Total count of all users Get-MgUser -CountVariable totalUsers -ConsistencyLevel eventual -Top 1 | Out-Null Write-Host "Total users: $totalUsers" ``` ### Breakdown by user type and status ``` # Member users only Get-MgUser -Filter "userType eq 'Member'" -CountVariable memberCount -ConsistencyLevel eventual -Top 1 | Out-Null # Guest users only Get-MgUser -Filter "userType eq 'Guest'" -CountVariable guestCount -ConsistencyLevel eventual -Top 1 | Out-Null # Enabled users Get-MgUser -Filter "accountEnabled eq true" -CountVariable enabledCount -ConsistencyLevel eventual -Top 1 | Out-Null ```