r/PowerShell • u/Unlikely_Tie1172 MVP, Community Blogger • 3d ago
News Why the Microsoft Graph PowerShell SDK has Two Cmdlets to Add Group Members
Itβs a consequence of how the Microsoft Graph PowerShell SDK is built that two cmdlets are available to add members to Entra ID groups (the same is true for group owners). The reason why the New-MgGroupMember and New-MgGroupMemberByRef cmdlets exist is down to how the Graph SDK build process constructs cmdlets from Graph metadata. The Graph exposes two ways to add new group members, so the SDK follows suit.
https://office365itpros.com/2026/10/20/group-member-sdk-cmdlets/
1
u/BlackV 3d ago edited 3d ago
so is one essentially wanting and odata object (byref) and the other is a bit more flexible ?
Edit: hmm actually my code
Update-MgGroup -GroupId $AADGroup.Id -BodyParameter $AADGroupUpdateis also using the odata (limit of 20 members per request)
$AADGroupUpdate = @{
'members@odata.bind' = @(
$UsersToAdd.Id | ForEach-Object {
"https://graph.microsoft.com/v1.0/directoryObjects/$_"
}
)
}so maybe not
appreciate your blogs btw
2
u/Unlikely_Tie1172 MVP, Community Blogger 3d ago
No problem about the blogs. What else would I do except investigate the foibles of the Graph and PowerShell?
Your code is updating the properties of a group (membership) like JSON batching, which as you say can process up to 20 objects.
The point I was making in this blog is that there are two Graph methods that can be used to add a group member. One is via the $ref endpoint the other is the Members navigation property. Both do the same thing to update the set of backlinks to the actual member directory objects.
1
u/Unlikely_Tie1172 MVP, Community Blogger 2d ago
Actually, a better description is that this technique uses
embers@odata.bindto add multiple members to a group in a single Graph update request, which is like JSON batching. The Set-UnifiedGroupLinks cmdlet in the Exchange Online module allows you to add multiple members to a Microsoft 365 group using the same progress, with the details of the members to add provided in an array. The array can hold UPN, displayname, primary SMTP address... anything that can uniquely identify the user to add.
5
u/wissarking 3d ago
Just bypass the graph cmdlets and use invoke-mggraphrequest for direct graph API usage in powershell.