Share via


Deletesite: Stsadm operation (Windows SharePoint Services)

Applies To: Windows SharePoint Services 3.0

 

Topic Last Modified: 2009-05-21

Operation name: Deletesite

Description

Deletes a site collection from a Web application.

If the site collection is live, then you would use the url parameter to specify the URL of the site collection that should be deleted.

If the site collection is orphaned, then you would use the force parameter with the siteid parameter to specify the orphaned site collection that should be deleted from the content database. For more information, see the Remarks section.

Note

The force and siteid parameters to delete orphaned site collections were first introduced in Windows SharePoint Services 3.0 with Service Pack 2 (SP2).
The gradualdelete parameter was first introduced in the April Cumulative Update.

Syntax

For deleting a live site collection:

stsadm -o deletesite

**   -url <URL name>**

**\[-deleteadaccounts {True | False}\]**

**\[-gradualdelete\]**

For deleting an orphaned site collection:

**   -force**

**\[-gradualdelete\]**

**   -siteid <site ID>**

**   -databasename <database name>**

**   -databaseserver <database server name>**

Parameters

Parameter name

Value

Required?

Description

url

A valid URL name, such as http://server_name/sites/site_name

Yes

The URL of the site collection to be deleted.

deleteadaccounts

One of the following values:

  • True

  • False (default value)

No

Specifies whether an Active Directory account that is associated with a site collection should be deleted.

When in Active Directory account creation mode and the value of this parameter is True, Windows SharePoint Services 3.0 will also delete Active Directory accounts associated with the site collection from Active Directory. For additional information, see KB article 823507 Determine whether Windows SharePoint Services is in Active Directory account creation mode (https://go.microsoft.com/fwlink/?LinkId=109243&clcid=0x409).

gradualdelete

<none>

No

When this parameter is used, the site collection is marked as deleted, which immediately prevents any further access to its content. The data in the deleted site collection is then deleted gradually over time by a timer job instead of all at once, which reduces its impact on Windows SharePoint Services and SQL Server performance.

For additional information about the gradual delete timer job, see Job-gradual-site-deletion: Stsadm property (Windows SharePoint Services).

force

<none>

Yes

Specifies a forceful method to delete a site collection and bypasses lookup from the sitemap. This is used to delete orphan site collections from specific databases.

siteid

A valid GUID of the site collection, such as "e2a114b8-80c9-41f6-87bf-3feddf2ad9b6"

Yes

Specifies the ID of the site collection that should be deleted.

databasename

A valid name, such as "DB1"

Yes

Specifies the name of the content database that contains the site collections that should be deleted.

databaserver

A valid name, such as "DS1"

Yes

Specifies the name of the database server instance hosting the database that contains the site collections that should be deleted.

Remarks

In this article, the command-line syntax is displayed differently than the syntax in command-line help.

A site map contains site collections that are browsable and registered. Site collections that are not registered in the site map are commonly referred to as "orphaned" site collections.

Site collections typically become orphaned when they are in a content database that is being attached to a Web application, but the Web application already contains a site collection with the same Uniform Resource Locator (URL) path. Because site collections cannot share the same URL path in a Web application, only the first site collection registered in the site map will be accessible. All other site collections that use the same URL path cannot be registered in the site map and are considered orphans. The orphaned site collection data still exists, but you can only access it by detaching its content database from the current Web application, and then attaching it to a Web application that does not have a site collection registered at that URL path.

Examples

To delete an operational site collection named "https://server_name/sites/site_name" and removed accounts in Active Directory, type the following syntax:

stsadm -o deletesite -url https://server_name/sites/site_name -deleteadaccounts true

To delete an operational site collection named "https://server_name/sites/site_name", type the following syntax:

stsadm -o deletesite -url https://server_name/sites/site_name

To delete an orphaned site collection named "https://server_name/sites/site_name" from a database server named DS1 and a database name called DB1, perform the following steps:

  1. Use the enumallwebs operation to find the site whose URL matches "/sites/site_name". Its parent site collection XML tag (that is, the Site tag) should have an InSiteMap attribute that has a value equal to False. A value of False means this site collection is orphaned. For more information, see Enumallwebs: Stsadm operation (Windows SharePoint Services).

  2. Use the value of the Id attribute from the matching Site tag and use it as the value of the siteid parameter of the deletesite operation.

    For example:

    stsadm -o deletesite -force -siteid e2a114b8-80c9-41f6-87bf-3feddf2ad9b6 -databaseserver DS1 -databasename DB1