Nov 25 2022 07:02 AM
Hi all,
Sometimes I have the need to delete a team permanently to be able to use the site url and stuff again.
Process: Delete the Team, go to Azure and delete the group permanently, go to sharepoint and delete the site permanently. No big deal.
To make it easier I wanted to have a PowerShell script doing this job for me. I thought it is the easiest way to do it with the pnp module. Therefore, I use the following commands to delete the group. Works like a charm:
Remove-PnPMicrosoft365Group
Remove-PnPDeletedMicrosoft365Group
And know I face a problem: I can't delete the team site via PowerShell. I tried:
Remove-SPOSite (with the SPO module)
Remove-PnPTenantSite
In both cases I get the error message: This site belongs to a M365 group. To delete it, I have to delete the group. But thats what I already did.
Can anyone support here?
Nov 27 2022 12:09 AM - edited Nov 27 2022 12:11 AM
Have you tried running Get-AzureADMSDeletedGroup to see if the Group is still present after the hard delete?
Office Groups are retained for 30 days after a delete normally. Using the command above will give you a list of Office Groups marked for delete.
Use Remove-AzureADMSDeletedDirectoryObject to remove the group completely.
Nov 28 2022 12:42 AM
Remove-PnPDeletedMicrosoft365Group is doing the same job.
To make sure the group deletion is running successfully, I created a new group and deleted it with Remove-PnPDeletedMicrosoft365Group. Afterwards neither Get-AzureADMSDeletedGroup nor Get-AzureADMSGroup show the group.
Jan 21 2023 05:31 PM
@SYN_Dominik Did you ever figure this out? I am running into the same issue. Removing the teams site always says there's a group associated but I've already deleted the group and deleted it from the recycle bin.
Jan 22 2023 11:20 PM
Hi @kbeeveer46
unfortunately no update from my side.