Hello !Daniel Bradley
Thanks for reaching out!
As per my understanding, both cmdlets let you create a member in a group. New-MgGroupMember cmdlet adds a member to an Office 365/security group through the members navigation property whereas New-MgGroupMemberByRef creates new navigation property ref to members for group.
Sample query using New-MgGroupMember:
New-MgGroupMember -GroupId '987648e7-b23a-4328-bd46-f1bd431c2354' -DirectoryObjectId '6aqc50d3-fcbd-4727-a889-8ab232dfea01'
Here we are straightforwarding passing the value. This adds a member specified by the DirectoryObjectId to the specified group.
Sample query using New-MgGroupMemberByRef:
Import-Module Microsoft.Graph.Groups
$params = @{
"@odata.id" = "https://graph.microsoft.com/v1.0/directoryObjects/{id}"
}
New-MgGroupMemberByRef -GroupId $groupId -BodyParameter $params
We make use of HashTable while using above cmdlet.
Hope this helps.
If the answer is helpful, please click Accept Answer and kindly upvote. If you have any further questions about this answer, please click Comment.