Can’t delete a sharepoint site that used to have a group attached to it, but the group has long since been deleted?
Apparently, the sharepoint admin center is unable to handle this scenario, and just throws a “could not be deleted” error. Using fiddler the only extra info I could get was an underlying 500 Internal Server Error Microsoft.Office.Server.Directory.DirectoryObjectNotFoundException was thrown
Obviously that directory object not found means the office 365 group. Fora seem to point to MS support for manual fixes, but since Microsoft Support has rarely been a pleasant experience for me I went over the PS module for SPO and found a MUCH faster fix, hope it also works for you!
- start PowerShell 5 (don’t use a newer version until the module supports it)
- install-module Microsoft.Online.SharePoint.PowerShell -force -scope currentuser (unless you already have the module installed)
- import-module Microsoft.Online.SharePoint.PowerShell
- Set-SPOSite -Identity https://xxx.sharepoint.com/sites/xxx -ClearGroupId
- Remove-SPOSite -Identity https://xxx.sharepoint.com/sites/xxx -noWait

