Delete and restore SharePoint site or subsite using Browser and PowerShell
Check out Best Alternative to InfoPath -> Try Now
This SharePoint tutorial, we will discuss how to delete and restore SharePoint site using PowerShell and by using browser.
The same way we can delete sites or subsites using browser and PowerShell in SharePoint 2013/2016 or SharePoint Online.
SharePoint 2016 Tutorial Contents
Follow the below steps to delete site using a browser in SharePoint Online as well as SharePoint on-premises.
Open your SharePoint 2013 online site, then Click on settings -> Site Settings. Then from Site Actions click on “Delete this site”. This will show you a warning message, there click on the Delete button as shown in the fig below:
But here one problem will come if there will be subsites within that site. In that case, you might get the below error:
Sorry, something went wrong
There was a problem deleting Website “/MyTeamSubSite”. Sites that have subsites or certain apps can’t be deleted. Please try again after deleting all subsites and removing the apps.
To solve the issue we have to delete the child subsite first and then we can be able to delete the parent site.
Below is the PowerShell command to delete a site collection which includes all sites and subsites under it in SharePoint On-premises versions like SharePoint 2013/2016.
Add-PSSnapin “Microsoft.SharePoint.PowerShell” Remove-SPSite -Identity “http://win-pfcp2dgt8di/sites/EnjoySharePoint/” -GradualDelete -Confirm:$False
Below is the PowerShell command to delete a particular subsite in SharePoint 2013/2016.
Add-PSSnapin “Microsoft.SharePoint.PowerShell” $SiteURL = “http://win-pfcp2dgt8di/sites/EnjoySharePoint/MyTestSubSite/MySubSubSite/” $web = Get-SPWeb $SiteURL $web.Delete()
We can use the Remove-SPOSite cmdlet to delete a site collection in SharePoint online. This command will not delete the site collection permanently rather the site collection will be moved to Recycle Bin from where we can restore the site collection using Restore-SPODeletedSite cmdlet.
Below is the PowerShell cmdlet to delete site collection in SharePoint Online.
Import-Module Microsoft.Online.SharePoint.Powershell -Verbose Remove-SPOSite -Identity “https://onlysharepoint2013.sharepoint.com/teams/MyDeleteSiteColTest”
After executing this command, if you will open the Recycle Bin in SharePoint 2013 online admin center you will be able to see the deleted sites there like below:
If you want to restore the deleted site collection from the recycle bin then in the browser you can select the site and then click on Restore Deleted Items. It will restore the site collection. Otherwise, you can use the below PowerShell command.
Import-Module Microsoft.Online.SharePoint.Powershell -Verbose Restore-SPODeletedSite -Identity https://onlysharepoint2013.sharepoint.com/teams/MyDeleteSiteColTest
We can use the Remove-SPODeletedSite cmdlet to permanently delete the site from recycle bin. After this, you will not be able to restore the site.
Import-Module Microsoft.Online.SharePoint.Powershell -Verbose Remove-SPODeletedSite -Identity https://onlysharepoint2013.sharepoint.com/teams/MyDeleteSiteColTest
You may like following SharePoint site collection tutorials:
- Create SharePoint Site Collection and Site using Nintex Workflow for Office 365
- Create and delete subsites under SharePoint site collection programmatically using PnP CSOM
- 3 Different ways to Change Site Collection URL in SharePoint
- Bulk SharePoint Online Site Collection Creation using PowerShell
- Self-Service Site Collection in SharePoint 2013/2016
- Create Site Collection and Subsite in SharePoint Online using PowerShell
- Delete and Restore Site Collection using PowerShell in SharePoint Online
- Get all subsites from a site collection in SharePoint Online using CSOM
- Find content database name for site collection using PowerShell in SharePoint
- Managing Sub Site Model or Template at Site Collection Level in SharePoint
- SharePoint 2016 Fast Site Collection Creation using PowerShell
- How to make SharePoint site collection read only and restrict delete?
- Delete corrupted SharePoint site collection using PowerShell
This SharePoint tutorial learned, how to delete the SharePoint site or subsite from the browser in SharePoint 2013/2016/Online. Also, we saw how to delete the site using PowerShell in SharePoint 2013/2016 or SharePoint Online.
We also learn, how to remove site permanently from Recycle Bin in SharePoint Online? How to restore deleted site collection from Recycle Bin in SharePoint Online using PowerShell.
Download SharePoint Online Tutorial PDF FREE!
Get update on Webinars, video tutorials, training courses etc.