The knowledge base / All cheat sheets
● Always in your toolkitAbout the project ↗

Microsoft Graph query and paging basics cheat sheet

Find users with server-side filters and handle complete result sets.

Graph PowerShell Microsoft.Graph.Users; delegated User.Read.All.

Updated · Microsoft Graph · 7 min read

CommandWhat it does
Get-MgContextConfirm query context
Get-MgUser -Filter "startsWith(displayName,'Alex')" -Top 10Find a bounded set of matching users
Get-MgUser -All -Property Id,DisplayName,UserPrincipalNameRetrieve all result pages
Get-MgUser -UserId 'user@example.com' -Property Id,AssignedLicensesInspect assigned license identifiers

Walkthrough

Connect using the connection guide, verify Get-MgContext and use a tenant where directory reading is authorized.

Step 1: Confirm query context

Get-MgContext

Confirm the tenant and User.Read.All scope. The query examples below read user records and do not alter the directory.

Step 2: Find a bounded set of matching users

Get-MgUser -Filter "startsWith(displayName,'Alex')" -Top 10

Replace Alex with a relevant prefix. The filter is sent to Graph; Top 10 deliberately limits the returned sample and is not a tenant-wide count.

Step 3: Retrieve all result pages

Get-MgUser -All -Property Id,DisplayName,UserPrincipalName

Use only when a full user inventory is needed. -All traverses pages and can take time in large tenants; protect the resulting personal data.

Step 4: Inspect assigned license identifiers

Get-MgUser -UserId 'user@example.com' -Property Id,AssignedLicenses

Replace the UPN and inspect AssignedLicenses. SKU IDs need mapping to tenant license products; an assigned license alone does not establish service provisioning health.

Microsoft Graph official documentation