Recreate deleted owner groups for SharePoint sites connected with M365
If out-of-the-box (OOB) groups such as owners, members, or visitors, have been accidentally deleted from your SharePoint site, these steps will help you restore them.
End users can unintentionally delete default SharePoint groups, resulting in a groupless state.
Recovery process
The newly created owner group is not associated with the M365 group owners. If a user is added as owner through the modern permission interface, they do not receive permissions for the site by default. Check permissions.
Restore the connection
It is necessary to reconnect the M365 group owners to SharePoint owners. When a team site connected to M365, the M365 group owners are added to the SharePoint owner group.
Further details can be found in the article:
how the M365 group is associated with the SharePoint groups.
We need to run a script.
- connect-pnpOnline -Url https://[Yourdomain].sharepoint.com/sites/[Yourpage] -weblogin
- $m365GroupId = (get-pnpsite -Includes RelatedGroupId).RelatedGroupId
- $m365GroupOwnerClaims = "c:0o.c🙂federateddirectoryclaim provider🙂{0}_o" -f $m365GroupId.Guid.ToString()
- Add-PnPSiteCollectionAdmin -Owners $m365GroupOwnerClaims
- $owner = Get-PnPGroup -AssociatedOwnerGroup 🙂 select Title
- Add-PnPGroupMember -Group $owner.Title -LoginName $m365GroupOwnerClaims 🙂 Out-zero
AfterTo execute the script, the M365 group owners with the SharePoint owner groupconnected.