Inventory Entra users
Documentation: Microsoft Learn
Get-MgUser with -All pages through the whole directory instead of stopping at the first page, and -Property maps to the underlying $select so only the four requested properties come back.
The script
Script reader
Inspect before you run
Inspect the script below. It does not run in this browser.
Inspection only — no command has run.
Show reference output
Inspect this example’s structure
Read the command and its supplied arguments. This example requires real PowerShell or its module; this diagram does not execute it.
Get-MgUser -All -Property DisplayName,UserPrincipalName,AccountEnabled,CreatedDateTime | Select-Object DisplayName,UserPrincipalName,AccountEnabled,CreatedDateTime- Stage 1Get-MgUser
-All -Property - Stage 2Select-Object
Positional values or no named parameters
How it works
Get-MgUser with -All pages through the whole directory instead of stopping at the first page, and -Property maps to the underlying $select so only the four requested properties come back. Select-Object projects the same set for display, including CreatedDateTime, which is what makes recently provisioned accounts visible.
Adapting it
Add -Filter to narrow the query server-side before paging begins, since retrieving a hundred thousand users and filtering locally is the slowest available way to answer a narrow question.
Requirements
Microsoft.Graph module with a Connect-MgGraph session holding User.Read.All.
If the result is unexpected
The Entra user inventory stops early or is missing expected properties.
Graph pagination, selected properties, permissions or tenant context can limit the results.
- Confirm the Graph context and request the required properties with the appropriate paging behavior.
Validate the result
A known user and the requested fields appear, and the result count is checked against the query scope.
Keep the check reliable
Record tenant and selected properties; distinguish unavailable fields from empty values.
Primary documentation
Practise the script’s building blocks
Connect and read tenant users
Connect to the fictional tenant first. Connect with User.Read.All and return fictional tenant users.
The sandbox is visible now. Sign in with Google only when you run or check a task; commands and temporary files are discarded when you leave.
Run a command to inspect its result.