Tuesday, April 7, 2015

How to Remove a site collection Normally and Forcefully

To Remove a site collection Normally

Remove-SPSite "http://sitename/"

Apparently, the Remove-SPSite cmdlet cannot delete a site collection which is not fully provisioned, and this cmdlet doesn’t have a force flag.

To forcefully delete a site collection, use the SPContentDatabase.ForceDeleteSite method

$siteUrl = "http://sitename/"
$site = get-spsite $siteUrl
$siteId = $site.Id
$siteDatabase = $site.ContentDatabase
$siteDatabase.ForceDeleteSite($siteId, $false, $false)

No comments:

Post a Comment