Get-MgUser : How to get and export Microsoft Entra ID users using Graph PowerShell - ADManager Plus
 
 
 

How to get Microsoft Entra ID users using Get-MgUser

Getting Microsoft Entra ID users

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.

  • ADManager Plus
  • PowerShell
 

List Microsoft Entra ID users using ADManager Plus

  1. Log in to ADManager Plus and navigate to Microsoft 365 > Reports > User Reports.
  2. Under General User Reports, click Microsoft 365 users.
  3. Select the desired Microsoft 365 tenant from the Microsoft Tenant drop-down list.
  4. Select the desired groups or domains whose users you would like to fetch in the Filter By pop-up and click Generate.
Get Microsoft Entra ID users using ADManager Plus' predefined reports
 
 

Export reports in multiple formats, including HTML, CSV, and PDF.

 
 

Instantly assign or revoke Microsoft 365 licenses.

 
 

Schedule automatic report generation.

Get Microsoft Entra ID users using Microsoft Graph PowerShell

Prerequisites

Before using the Get-MgUser cmdlet, ensure the following:

  • The Microsoft Graph PowerShell module is installed. If not, install it using this script:
    Install-Module Microsoft.Graph -Scope CurrentUser
  • Connect to Microsoft Graph PowerShell with the required permissions to fetch Microsoft Entra ID users.
    Connect-MgGraph -Scopes "User.Read.All","Group.ReadWrite.All"

Using the Get-MgUser command to get Microsoft Entra ID users

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 use cases and scripts using the Get-MgUser cmdlet

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

Supported parameters

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.

Limitations of using Graph PowerShell scripts to get Microsoft Entra ID users

  • Graph PowerShell requires IT admins to upgrade from Azure AD PowerShell and have familiarity with PowerShell scripting.
  • The Microsoft Graph API imposes throttling limits, which may affect performance when fetching users in bulk.
  • The scripts may require extra effort to format and export data for reporting purposes.
  • It demands technical expertise to troubleshoot errors.
  • The lack of an intuitive interface makes the overall experience less user-friendly, particularly for those new to scripting.

Highlights of using ADManager Plus to get Microsoft Entra ID users

  • ADManager Plus comes with an intuitive interface that streamlines the report generation process.
  • It offers comprehensive, customizable reports with options to schedule and automate report generation.
  • It supports on-the-fly management actions to manage users instantly.
  • It is optimized for large-scale environments and does not require any scripts for bulk operations.
  • It allows reports to be exported in various formats, such as CSV or HTML, in a few clicks.

Get the Microsoft Entra ID user list effortlessly with ADManager Plus

 
  • Fetching Microsoft Entra ID Users
  • Using ADManager Plus
  • Using Microsoft Graph PowerShell
  • Supported parameters
  • Graph PowerShell limitations
  • Highlights of ADManager Plus
The one-stop solution to Active Directory Management and Reporting
Email Download Link