IT administrators are often tasked with generating user lists for compliance and audit purposes. While Graph PowerShell's Get-MgUser command, an alternative to the Get-AzureADuser command, can be used to obtain and export Microsoft Entra ID users and their details, its complexity and non-intuitive interface make it a challenging option. On the other hand, ADManager Plus, a Microsoft 365 management and reporting tool, simplifies the process, allowing administrators to quickly generate and export user reports in just a few clicks.
Export reports in multiple formats, including HTML, CSV, and PDF.
Instantly assign or revoke Microsoft 365 licenses.
Schedule automatic report generation.
Before using the Get-MgUser cmdlet, ensure the following:
Install-Module Microsoft.Graph -Scope CurrentUser
Connect-MgGraph -Scopes "User.Read.All","Group.ReadWrite.All"
The Get-MgUser cmdlet can be used in Microsoft Graph PowerShell to fetch Microsoft Entra ID users. Here's the syntax:
Get-MgUser
[-ExpandProperty <String[]>]
[-Property <String[]>]
[-Filter <String>]
[-Search <String>]
[-Sort <String[]>]
[-Top <Int32>]
[-ConsistencyLevel <String>]
[-ResponseHeadersVariable <String>]
[-Headers <IDictionary>]
[-PageSize <Int32>]
[-All]
[-CountVariable <String>]
[-ProgressAction <ActionPreference>]
[<CommonParameters>]
Example 1: List all users with their email addresses
Get-MgUser -All -Select-Object DisplayName, Mail
Example 2: Find account-enabled users
Get-MgUser -All -Filter "accountEnabled eq true"
Example 3: Retrieve users and order them by display name
Get-MgUser -All -OrderBy DisplayName
The following table contains some parameters that can be used along with the Get-MgUser command to efficiently fetch Microsoft Entra ID users.
| Parameters | Description |
|---|---|
| -All | This parameter retrieves all users without default pagination limits. |
| -Filter | This parameter filters users based on attributes and values. |
| -UserId | This parameter retrieves users based on their unique identifiers, such as user principal name or object ID. |
| -Property | This parameter retrieves specific attributes of users. |
| -ConsistencyLevel | This enables advanced query capabilities for improved performance. |