I would like to know how to add a user as a member to a Microsoft Planner Plan using Microsoft Graph API and PowerShell. I know that the membership to a plan is ruled by the membership to the M365 Group. The user is already the owner of the group to which the planner belongs but still, he can not see the plan into his plan list.
How to do this? What do I miss here?
I did not find any example of how to achieve this.
The group is already created and cannot be created only to create the plan as well.
If you find a solution that allows me to add the users during the creation of the plan I'll be more than happy to see it as well. Here is the snippet I am using to create the plan. It is working perfectly.
$uri = "https://graph.microsoft.com/beta/planner/plans"
$GroupID="GUID of the group"
$UserAccessToken="token generated and working"
$headers = @{"Authorization" = "Bearer $UserAccessToken" }
$planTitle = "My plan"
$body = @{
"owner" = "$GroupID";
"title" = "$planTitle"
}
$fbody = ConvertTo-Json -InputObject $body
$response = Invoke-RestMethod -Method Post -Uri $uri -Headers $headers -Body $fbody -ContentType "application/json"
Thank you