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.
Before using the New-MgGroupMemberByRef cmdlet, ensure the following:
Install-Module Microsoft.Graph -Scope CurrentUser
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>]
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
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. |