Priority
(Medium) I'm annoyed but I'll live
Description
Removing sites and groupified sites does not work correctly
Issues 1
If I try to delete a groupified site, this does not work correctly:

What happens is that it removes the group using the Graph, and then tries to remove the site using the sharepoint API. The only problem is that the site cannot be removed because it's connected to the group. Thus it throws an exception, but the exception is caught by a try-catch that interprets it as something different.
Long story short, this code is bad. It does not do what you'd expect it to do.
The result is that the group is deleted, but the site is not deleted at all.
Issue 2
I can use --fromRecycleBin when deleting a site that is not in the recycle bin. SharePoint will delete the site for you.
I find this questionable. It should throw an error if it's not in the recycle bin.
Issue 3
I can use --fromRecycleBin on groupified sites. This deletes the site (and skips the recycle bin), but leaves the group as is. It's not even deleted
Issue 4
The command claims that you cannot use --skipRecycleBin on groupified sites. however, this functionality IS available on aad o365group remove, so I guess we should implement it here as well.
Steps to reproduce
just try it out
Expected results
sites and groups correctly deleted or moved to the recycle bin
Actual results
odd results...
Additional Info
Part of the solution is to start using the GroupManager API for groupified sites:
https://contoso-admin.sharepoint.com/_api/GroupSiteManager/Delete
{
"siteUrl": "https://contoso.sharepoint.com/sites/sales"
}
This will delete the site AND the group in one call.
This API is already implemented for deleting orphaned sites. But it should be used in any m365 group deletion call.
For --skipRecycleBin, the implementation on aad o365group remove can serve for inspiration
Implementation
The issue will be solved if the following points have been implemented:
Priority
(Medium) I'm annoyed but I'll live
Description
Removing sites and groupified sites does not work correctly
Issues 1
If I try to delete a groupified site, this does not work correctly:
What happens is that it removes the group using the Graph, and then tries to remove the site using the sharepoint API. The only problem is that the site cannot be removed because it's connected to the group. Thus it throws an exception, but the exception is caught by a try-catch that interprets it as something different.
Long story short, this code is bad. It does not do what you'd expect it to do.
The result is that the group is deleted, but the site is not deleted at all.
Issue 2
I can use
--fromRecycleBinwhen deleting a site that is not in the recycle bin. SharePoint will delete the site for you.I find this questionable. It should throw an error if it's not in the recycle bin.
Issue 3
I can use
--fromRecycleBinon groupified sites. This deletes the site (and skips the recycle bin), but leaves the group as is. It's not even deletedIssue 4
The command claims that you cannot use
--skipRecycleBinon groupified sites. however, this functionality IS available onaad o365group remove, so I guess we should implement it here as well.Steps to reproduce
just try it out
Expected results
sites and groups correctly deleted or moved to the recycle bin
Actual results
odd results...
Additional Info
Part of the solution is to start using the GroupManager API for groupified sites:
This will delete the site AND the group in one call.
This API is already implemented for deleting orphaned sites. But it should be used in any m365 group deletion call.
For
--skipRecycleBin, the implementation onaad o365group removecan serve for inspirationImplementation
The issue will be solved if the following points have been implemented:
spo site remove- the GroupManager API is used for groupified sites.spo site remove- the--skipRecycleBinflag can be used for groupified sites as well.spo site remove- for non-groupified sites,--fromRecycleBinchecks if a site is actually in the recycle bin before deleting it. It will throw an error if not.spo site remove- for groupified sites--fromRecycleBinchecks if a group is a deleted group using the graph API and removes it if it is.