Friday, June 5, 2015

How to Delete Site Collection using PowerShell in SharePoint

To delete any SharePoint site collection, You have use SharePoint Central Administration site. Navigate to :

  • SharePoint 2013 Central Administration >> Application Management 
  • Click on Delete a site collection link under Site Collections group
    how to delete site collection powershell
  • Select the site collection to delete
    delete site collection powershell sharepoint 2013
  • Click on Delete button to delete a site collection in SharePoint.
    powershell script to delete a site collection
Delete host named site collection with PowerShell
Host named site collections can be managed only through PowerShell! Central Admin doesn't offer the provision to delete Host named site collections as it offers for Path-based sites. Following are some examples of deleting SharePoint 2013/2010 site collections using PowerShell.

Delete site collection using PowerShell
To delete site collection through PowerShell, use Remove-SPSite cmdlet.
Remove-SPSite -Identity "<Site-Collection-URL>" 
Remove-SPSite -Identity "" 

Force delete SharePoint site collection PowerShell
If you face any difficulty in deleting SharePoint site collection either from Central Admin or with PowerShell, you can force delete as:
#Get the site collection to delete
$Site = Get-SPSite http://site-collection-url

#Get the content database of the site collection
$SiteContentDB = $site.ContentDatabase 

#Force delete site collection
$SiteContentDB.ForceDeleteSite($Site.Id, $false, $false)
If you delete a site collection Remove-SPDeletedSite cmdlet or force delete a site collection with $GradualDelete parameter to $True, Then you'll not be able to recover it using Restore-SPDeletedSite cmdlet! (You need content database backup instead!)

Bulk delete site collections with PowerShell in SharePoint 2013 
How about bulk deleting multiple site collections? Say, You want to delete all site collections under the given managed path: /Sites?
Get-SPSite "*" -Limit ALL | Remove-SPSite -Confirm:$false

PowerShell to delete all site collections under a web application:
If you don't want to send your SharePoint sites to recycle bin and would like to remove them permanently, use:
#Web Application URL

#Get Each site collection and delete
Get-SPWebApplication $WebAppURL | Get-SPSite -Limit ALL | Remove-SPSite -Confirm:$false

Related posts:

You might also like:
SharePoint Usage Reports
Usage reports, collaboration and audit for SharePoint.
Document SharePoint Farm
Automatically generate SharePoint documentation.

Check out these SharePoint products:

No comments :

Post a Comment

Please Login and comment to get your questions answered!

You might also like:

Related Posts Plugin for WordPress, Blogger...