0

This question already has an answer here:

I run the following command:-

get-spdeletedsite

which showed me a list of deleted site collections, now i run the following to remove the deleted sites as follow:-

remove-spdeletedsite 032**********

but i got the following error :-

unable to find the specified path

enter image description here

now i try to run the following script :-

Add-PSSnapin Microsoft.SharePoint.PowerShell
$CorruptSites = "http://***/sites/***"

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
}

but i got the following exception also:-

http://***/sites/*** :
Get-SPSite : Cannot find an SPSite object with Id or Url: http://***/sites/***.
At C:\Users\***\Desktop\1.ps1:10 char:9
+ $site = Get-SPSite $CorruptSite
+         ~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (Microsoft.Share...SPCmdletGetSite:SPCmdletGetSite) [Get-SPSite], SPCmdletPipeBindException
    + FullyQualifiedErrorId : Microsoft.SharePoint.PowerShell.SPCmdletGetSite

so can anyone adivce on this please ?i remember that i tried to remove this site collection using the central administration UI. but it raised an exception and the site content database and site collection administrator became empty,, so is there a way to remove corrupted deleted site collection ?

marked as duplicate by Benny Skogberg Jul 18 '15 at 7:07

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • little confusing, if you are seeing the site collection using get-spdeletedsites then how can you see that in the central admin....Only deleted sites showed in that command. you tryong to remove the teamout site collection...did you try remove-spdeletedsite /sites/teamout – Waqas Sarwar MVP Jul 16 '15 at 16:54
  • You could try to detach and attach the DB, that was one way to clear corrupted sites in the past when powershell or stsadm wouldn't work. – Eric Alexander Jul 16 '15 at 17:27
  • @WaqasSarwarMCSE i tried the following "remove-spdeletedsite <i type the site id >" . now i type "remove-spdeletedsite /sites/teamout" but i got the same error "Unable to find the specified file." – john Gu Jul 17 '15 at 0:42
  • @EricAlexander as i know detach/attach DB are done to web applications and not site collections ? is this correct, as inside my web application i have other site collections ... so how i can process this? – john Gu Jul 17 '15 at 1:06
  • 1
    try this bfy.tw/r8c – Eric Alexander Jul 17 '15 at 1:09