Delete and Restore Site Collection using PowerShell in SharePoint Online Office 365

SharePoint online powershell delete site collection

This SharePoint Online PowerShell tutorial explains, delete site collection SharePoint online PowerShell. We will also see how to restore deleted site collection using PowerShell in SharePoint Online Office 365. We will also discuss how to delete SharePoint Online site collection permanently using PowerShell in SharePoint Online Office 365.


New to Office 365 SharePoint Online? Get Office 365 Enterprise E3 Subscription & Try out all the features

If you are new to PowerShell SharePoint Online, then you read following PowerShell SharePoint Online tutorial:

We can use Remove-SPOSite PowerShell cmdlets to move the site collection to the recycle bin in SharePoint Online Office 365. This command will not delete the site collection permanently instead it will just move to the recycle bin in SharePoint Online.

Just to let you know that you must be a SharePoint Online global administrator and a site collection administrator to run the below cmdlet.

Even if you are a SharePoint Online global administrator, it will not allow you to delete the site collection if you are not a site collection administrator.

PowerShell Command to delete SharePoint online site collection

Below is the PowerShell command to delete the site collection in SharePoint Online Office 365.

Import-Module Microsoft.Online.SharePoint.PowerShell -DisableNameChecking

Connect-SPOService -Url https://onlysharepoint2013-admin.sharepoint.com -credential bijay@onlysharepoint2013.onmicrosoft.com

Remove-SPOSite -Identity https://onlysharepoint2013.sharepoint.com/sites/MySite -Confirm:$false

Restore Site Collection using PowerShell SharePoint Online
delete site collection SharePoint online PowerShell

Once you run the command, the site will be moved to the recycle bin in SharePoint Online. See the fig below:

Delete Site Collection using PowerShell in SharePoint Online
Delete Site Collection using PowerShell in SharePoint Online

Delete SharePoint Online Site Collection Permanently using PowerShell

If you want to permanently delete the site from the recycle bin, you can run Remove-SPODeletedSite command like below:

Import-Module Microsoft.Online.SharePoint.PowerShell -DisableNameChecking

Connect-SPOService -Url https://onlysharepoint2013-admin.sharepoint.com -credential bijay@onlysharepoint2013.onmicrosoft.com

Remove-SPODeletedSite -Identity https://onlysharepoint2013.sharepoint.com/sites/MySite -Confirm:$false

The above PowerShell cmdlets delete a SharePoint Online site collection permanently.

Restore Delete Site Collection using PowerShell in SharePoint Online Office 365

Similarly, if you want to restore the deleted site collection from recycle bin in SharePoint Online Office 365, you can run the below PowerShell cmdlets.

Import-Module Microsoft.Online.SharePoint.PowerShell -DisableNameChecking

Connect-SPOService -Url https://onlysharepoint2013-admin.sharepoint.com -credential bijay@onlysharepoint2013.onmicrosoft.com

Restore-SPODeletedSite -Identity https://onlysharepoint2013.sharepoint.com/sites/MySite

SharePoint online powershell delete site collection
SharePoint online powershell delete site collection

Once you run the above command, the site collection will be get restored from recycle bin in SharePoint Online Office 365.


You may like following SharePoint PowerShell tutorials:

Hope this PowerShell SharePoint tutorial explains how to delete site collection in SharePoint Online using PowerShell?

How to permanently delete site collection using PowerShell in SharePoint Online Office 365? Also, how can we restore a deleted site collection from recycle bin using PowerShell in SharePoint Online Office 365?

Check out Best Alternative to InfoPath -> Try Now

FREE SHAREPOINT 2019 PDF

(Installation & Features)



About Bijay Kumar

I am Bijay from Odisha, India. Currently working in my own venture TSInfo Technologies in Bangalore, India. I am Microsoft Office Servers and Services (SharePoint) MVP (5 times). I works in SharePoint 2016/2013/2010, SharePoint Online Office 365 etc. Check out My MVP Profile.. I also run popular SharePoint web site SharePointSky.com

View all posts by Bijay Kumar →