0

I have a very strange situation - two sub webs were created through some code but it errored out part way through the process and now I am left two webs I can't seem to delete. The strange part is that I can see them as an error if I trying to create a new web with the same URL (it complains it already exists) and I get see them in PowerShell using Get-SPWeb for the parent site then enumerating the Webs property. Using the C# server side object model I can't even see the sites or get a reference to delete them!

Help! How can I delete these rogue sites?

Examples:

PowerShell

$web = Get-SPWeb http://server/web
$web.Webs

Url
---
http://server/web/OldMeetingSite
http://server/web/NewMeetingSiteA
http://server/web/NewMeetingSiteB

C# Server Side Object Model

using (SPSite site = new SPSite("http://server"))
{
    using (SPWeb web = site.OpenWeb("web"))
    {
        foreach (SPWeb sub in web.Webs)
        {
            Console.WriteLine(sub.Url);
        }
    }
}
// output - only one site?!?!?
http://server/web/OldMeetingSite

Note: I can get some quasi-reference to the webs through PowerShell $webs.Webs[1] but the call to .Delete() fails with the message There is no web named "/web/NewMeetingSiteA".

1

Per this site:

http://sharenotes.wordpress.com/2007/11/19/deleting-purging-removing-orphaned-sites-or-site-collections/

Give this a try to see if these are orphaned sites:

stsadm -o databaserepair -url http://(your site collection's URL) -databasename (site content database)

And then if you do find them on the list, run this:

stsadm -o databaserepair -url http://(your site collection's URL -databasename (site content database) -deletecorruption

If that doesn't work, the page listed has a SQL call that may be able to remove it directly from there. I strongly recommend you back up the entire content database before attempting this, as if you accidentally delete a site you didn't want to delete, Microsoft does not support what you're doing and will not be able to do much to help you get it back.

  • The first command simply gave back <OrphanedObjects Count="0" /> - I may need to try one of the more exotic solutions. Thanks though - I didn't know this command existed! – Goyuix Apr 30 '14 at 14:30
  • Yeah, the world of stsadm is a bit obscure nowadays, but there are still a few things that Powershell can't do that it can. – NotVonKaiser May 1 '14 at 0:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.