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 Answer 1

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.

2
  • 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! Commented Apr 30, 2014 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. Commented May 1, 2014 at 0:48

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.