What if you need to update thousands of m365 groups? E.g. membership – to add a group owner or member.
In my case, it was Microsoft 365 ownerless groups policy… Details are here but in short, I needed to update ownership for 10,000 m365 groups adding 10 accounts to group owners, 1,000 groups per account.
And I figured out for myself that the fastest way is to use Microsoft Graph API with PowerShell parallel trick. Here is the PowerShell code:
$groups | ForEach-Object -Parallel {
$owner = "user2del27@vladslab.onmicrosoft.com"
Add-PnPMicrosoft365GroupOwner -Identity $_.Id -Users $owner
} -ThrottleLimit 50
In my environment, it took ~ 8 seconds per 1,000 groups.