Get-MgUser
Use Get-MgUser to query Microsoft Graph users with pagination and explicit properties. See Microsoft.Graph module requirements and examples.
Documentation: Microsoft Learn — Get-MgUser
Common usage
Get-MgUser -ErrorAction StopThis is a usage example, not the complete parameter-set reference. Follow Microsoft Learn below for supported parameters and version details.
See the command anatomy
Read the command and its supplied arguments. This example requires real PowerShell or its module; this diagram does not execute it.
Get-MgUser -ErrorAction Stop- Stage 1Get-MgUser
-ErrorAction
Try it
PowerShell example · browser support is limited.
Execution scope: The full example below requires PowerShell outside this browser. You can edit this runner to use the supported practice commands; unsupported syntax returns an explanation.
Follow the objects
Run the command to inspect each stage.
Examples
Get-MgUser -ErrorAction Stop
Get-MgUser -ErrorAction StopShow reference output
Sample output · fictional data, shaped like the real thing
DisplayName UserPrincipalName AccountEnabled ----------- ------------------ -------------- Adele Vance adelev@contoso.com True Alex Wilber alexw@contoso.com True
Practical use and troubleshooting
Practical scenario: Use Get-MgUser when you need to query Microsoft Graph users with pagination and explicit properties. Start with one identified target and inspect the returned values before extending the operation to a list. Keep the identity in your report so you can trace each result back to the object or path that produced it.
Common error and fix: A missing property may not be in the default response. Request it with -Property, and use -All for a complete paged collection rather than treating the first response as the full directory. In an unattended script, capture this failure with its original error record and record which target failed. An empty result and an unsuccessful query must remain distinguishable in the final report.
See also: Get-ADUser. Get-MgUser reads cloud directory users through Graph; Get-ADUser reads Active Directory users through the AD module. Similar names do not make their identities or permission models interchangeable. Read the linked command before substituting it; similar names do not imply identical inputs or output.
Put this command to work
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.
Inspect starting data
Supported syntax
Virtual files
Recap
Get-MgUser Use Get-MgUser to query Microsoft Graph users with pagination and explicit properties. See Microsoft.Graph module requirements and examples.
Next: Get-MgAuditLogSignIn