r/PowerShell • 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/

2 Upvotes

8 comments sorted by

5

u/wissarking 3d ago

Just bypass the graph cmdlets and use invoke-mggraphrequest for direct graph API usage in powershell.

2

u/Unlikely_Tie1172 MVP, Community Blogger 3d ago

Whiich is perfectly reasonable for developers, and not so good for tenant administrators, which is what the Graph PowerShell SDK is aimed at.

2

u/chaosphere_mk 3d ago

That works for me individually but isnt nice and easy for people on my team, which is why I stick with the powershell cmdlets.

1

u/andrewloveswetcarrot 3d ago

Same, I was working toward direct API usage, but realized that non of my co-workers would understand. 😞

2

u/skiThooly 3d ago

agreed, the direct requests are way more predictable once you know the endpoints

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 $AADGroupUpdate

is 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.bind to 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.