Forum Discussion
Remove-SPOSite : This site belongs to an Office 365 group. To delete the site, you must delete group
Hi
when I try to delete sitecol using powershell script I am getting error:
Remove-SPOSite : This site belongs to an Office 365 group. To delete the site, you must delete the group.
At line:7 char:1
+ Remove-SPOSite -Identity "https://xyz.sharepoint.com/sites/del1 ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Remove-SPOSite], ServerException
+ FullyQualifiedErrorId : Microsoft.SharePoint.Client.ServerException,Microsoft.Online.SharePoint.PowerShell.RemoveSite
I executed the below comments no luck...
Set-SPOSite -Identity "https://xyz.sharepoint.com/sites/del1" -LockState "unlock"
Set-SPOSite -Identity "https://xyz.sharepoint.com/sites/del1" -Owner "xyz@abc.onmicrosoft.com" -NoWait
Remove-SPOSite -Identity "https://xyz.sharepoint.com/sites/del1" -Confirm:$false
Remove-SPODeletedSite -Identity "https://xyz.sharepoint.com/sites/del1" -Confirm:$false
Why I am getting error like this... and how to resolve this.
- As the message says, delete the Office 365 Group tied to the site and you are done: https://docs.microsoft.com/en-us/powershell/module/exchange/users-and-groups/remove-unifiedgroup?view=exchange-ps