Permanently delete SharePoint Online Site-Collection

For SharePoint administrators, there was quite a radical change with the introduction of O365/SharePoint Online. One of the biggest changes for them were the limitations to the Administration Portal. The Central Admin allowed admins perform a plethora of admin tasks which were either not anymore allowed or were no longer available via the UI. Of course many admins did prefer the PowerShell route, some tasks were just easier via the UI.

One such task that I have seen most admins perform via the UI was the deletion of a site-collection including the recycle bin. This is commonly done when a site provision failed and the same site needed to be provisioned again. However, deleting a site-collection was not enough. It was still in the recycle bin, and SharePoint was always smart to prevent you from creating another site-collection while a site with the same URL was present in the Recycle Bin.

In on-premises, it is possible for admins to access the Recycle Bin via CA and delete the site. This capability is however not an option on O365. Of course, PowerShell to the rescue.

In this case, I was more tempted to create 
such a solution since the remote provisioning engine didn't act quite reliably. Many a times, a number of sites were not provisioned correctly, thus requiring re-provisioning and that of course demanded that the old site be deleted.

Using the standard SPO cmdlets this script keeps asking for site-urls to be deleted and then deletes all sites (including delete from Recycle bin) at one go. And you are ready to re-provision again.

The script is available on Github at DeleteSiteCollection.ps1.

My script takes the site urls as input from the user, however this can easily be changed to read a different source such as a file.


Comments

Popular posts from this blog

Automate Import of Functions/WebAPI in Azure API Management as backend and using OpenAPI definition and Terraform

Transcripts with Microsoft Bot Framework v4

Managing built-in cache in Azure API Management