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

This SharePoint Online PowerShell tutorial explains, delete site collection SharePoint online PowerShell. We will also see how to restore the 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.

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 sharepoint online site collection using powershell

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

Delete sharepoint online site collection using powershell

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 Deleted Site Collection using PowerShell in SharePoint Online Office 365

Similarly, if you want to restore the deleted site collection from the 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
Delete and Restore Site Collection using PowerShell in SharePoint Online

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

You may like following SharePoint PowerShell tutorials:

I 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 the recycle bin using PowerShell in SharePoint Online Office 365?

free sharepoint training

SharePoint Online FREE Training

JOIN a FREE SharePoint Video Course (3 Part Video Series)

envelope
envelope

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

>