About Me

My photo
Muthupet, TamilNadu, India
SharePoint 2010

Tuesday, June 26, 2018

Remove orphaned Site Collection URLS with no refrence to Content Database

During the Migration or Patching..

These sites assumes that content database got removed manually and site collection entries remains in config db. you need to type your corrupt site collection names in below $CorruptSites separated by comma in below script block and run as administrator in PowerShell.

This will fully remove referred site collection from Farm.

Add-PSSnapin Microsoft.SharePoint.PowerShell $CorruptSites = "http://rk-sps.com/sites/a","http://rk-sps.com/sites/b" Function DeleteCorruptSite { param($CorruptSite) Write-Host $CorruptSite : -foreground red $site = Get-SPSite $CorruptSite $siteId = $site.Id $siteDatabase = $site.ContentDatabase $siteDatabase.ForceDeleteSite($siteId, $false, $false) Write-Host --Deleted from Content DB -foreground green } foreach ($CorruptSite in $CorruptSites) { DeleteCorruptSite $CorruptSite }

No comments:

Post a Comment