SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How to delete a website which is having subsites in sharepoint 2010? I dont like to go to down level and start up deleting? i would like to delele site and subsites at a time?

share|improve this question

Do you have the Publishing Infrastructure enabled? If so I believe you can do this from the Site Actions/Manage Content and Structure option. Just chose delete from the menu.

share|improve this answer

If you're trying to do this via the Object Model, then you're going to have to recurse down through the sites and delete from the bottom up.

I've put together a function to do this (see below). However, I've also put together a more integrated solution in the form of an extension method, which can be found on my blog. SPFix: Deleting a site with subsites programmatically

public static void DeleteWeb(SPWeb web)
{
    foreach (SPWeb subWeb in web.Webs)
    {
        DeleteWeb(subWeb);
    }

    web.Delete();
}
share|improve this answer

Depends on how you want to remove the site and it's corresponding sub-sites, whether by Powershell or programatically.

If you are wanting to do this programatically, according to technet, you should be able to just use:

Remove-SPSite -Identity "http://sitename" -GradualDelete -Confirm:$False

Otherwise, the other code related snippet and link provided by @Stuart should work.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.