How to add members to Microsoft Entra ID groups using New-MgGroupMemberByRef

Adding members to Microsoft Entra ID groups

Admins add members to Microsoft Entra ID groups to control access to resources, streamline collaboration, and enforce security policies. While Graph PowerShell's New-MgGroupMemberByRef command—an alternative to the Add-AzureADGroupMember PowerShell command, can be used to add members to Microsoft Entra ID groups, it is both a time-consuming and error-prone process, especially when adding members in bulk. On the other hand, ADManager Plus, a Microsoft 365 management and reporting tool, streamlines the task, enabling administrators to quickly add members to Microsoft Entra ID groups with just a few clicks.

  • ADManager Plus
  • PowerShell
 

Adding members to Microsoft Entra ID groups using ADManager Plus

  1. Log in to ADManager Plus and navigate to Microsoft 365 > Management > Group Management.
  2. Under Group Member Management, select the type of Microsoft Entra ID group you want to add members to. You can add members to distribution groups, mail-enabled security groups, Microsoft 365 groups, and security groups.
  3. From the Add to groups field, select the group(s) that you want to add members to.
  4. From the Microsoft 365 Tenant drop-down list, select the desired tenant.
  5. In the Select User(s) field, search for the users you wish to add to the selected groups and click Find. You can also upload a CSV file to add users in bulk.
  6. Select from the list of members generated, and click Apply.
Add members to Microsoft Entra ID groups using ADManager Plus

Adding members to Microsoft Entra ID groups using Microsoft Graph PowerShell

Prerequisites

Before using the New-MgGroupMemberByRef cmdlet, ensure the following:

  • The Microsoft Graph PowerShell module is installed. If not, install it using this script:
    Install-Module Microsoft.Graph -Scope CurrentUser

Using the New-MgGroupMemberByRef to add members to Microsoft Entra ID groups

The New-MgGroupMemberByRef cmdlet can be used in Microsoft Graph PowerShell to add members to Microsoft Entra ID groups. Here's the syntax:

New-MgGroupMemberByRef
-GroupId <String>
[-ResponseHeadersVariable <String>]
-OdataId <String>
[-AdditionalProperties <Hashtable>]
[-Headers <IDictionary>]
[-PassThru]
[-ProgressAction <ActionPreference>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]

Example use cases and scripts using the New-MgGroupMemberByRef cmdlet

Add a member to a group

Import-Module Microsoft.Graph.Groups
$params = @{
"@odata.id" = "https://graph.microsoft.com/v1.0/directoryObjects/{id}"
}
New-MgGroupMemberByRef -GroupId $groupId -BodyParameter $params

Supported parameters

The following table contains some parameters that can be used along with the New-MgGroupMemberbyRef command to efficiently add members to Microsoft Entra ID groups.

Parameters Description
-GroupId This parameter displays the unique identifier of the group.
-Headers This parameter allows you to add optional headers to the request.
-OdataId This parameter displays the entity reference URL of the resource.
-PassThru This parameter returns true when the command succeeds.
-WhatIf This parameter displays the outcome if the cmdlet is executed.

Limitations of using Graph PowerShell scripts to add members to Microsoft Entra ID groups

  • Graph PowerShell requires IT admins to upgrade from Azure AD PowerShell and have familiarity with PowerShell scripting.
  • When using the Microsoft Graph API, you are limited to adding a maximum of 20 members in a single request. API throttling limits may impact performance when adding users in bulk.
  • Identifying and troubleshooting errors can be time-consuming and require technical expertise.
  • The scripts may require extra effort to format and export data for reporting purposes.
  • No built-in graphical interface or user-friendly reports, making management and monitoring difficult for administrators.

Highlights of using ADManager Plus to add members to Microsoft Entra ID groups

  • Get reports and manage Microsoft Entra ID groups with an easy-to-use interface, eliminating the need for complex PowerShell scripting or Graph API knowledge.
  • Add unlimited members to groups simultaneously by importing a CSV file, without throttling or API restrictions.
  • Generate more than 200 prepackaged reports, with options to customize and export them in various formats, like CSV or HTML.
  • Use prebuilt or custom templates to standardize management and reporting tasks.
  • Delegate specific management and reporting tasks to technicians without granting them excessive permissions.

Simplify Microsoft Entra ID group management with ADManager Plus

 
  • Add members to Microsoft Entra ID Groups
  • Add members to Microsoft Entra ID groups using ADManager Plus
  • Add members to Microsoft Entra ID groups using Microsoft Graph PowerShell
  • Limitations of using Graph PowerShell scripts to add members to Microsoft Entra ID groups
  • Highlights of using ADManager Plus to add members to Microsoft Entra ID groups
The one-stop solution to Active Directory Management and Reporting
Email Download Link