Applies to: SharePoint Server 2010, SharePoint Foundation 2010

Topic Last Modified: 2010-07-21

Tests a content database.

Test-SPContentDatabase [-Identity] <SPContentDatabasePipeBind> [-AssignmentCollection <SPAssignmentCollection>] [-DatabaseCredentials <PSCredential>] [-ServerInstance <SPDatabaseServiceInstancePipeBind>] [-ShowRowCounts <SwitchParameter>]
Test-SPContentDatabase -Name <String> -WebApplication <SPWebApplicationPipeBind> [-AssignmentCollection <SPAssignmentCollection>] [-DatabaseCredentials <PSCredential>] [-ServerInstance <SPDatabaseServiceInstancePipeBind>] [-ShowRowCounts <SwitchParameter>]

This cmdlet contains more than one parameter set. You may only use parameters from one parameter set, and you may not combine parameters from different parameter sets. For more information about how to use parameter sets, see Cmdlet Parameter Sets.

Use the Test-SPContentDatabase cmdlet to test a content database against a Web application to verify all customizations referenced within the content database are also installed in the web application. This cmdlet can be issued against a content database currently attached to the farm, or a content database that is not connected to the farm. It can be used to test content databases from SharePoint 2010 Products and from SharePoint Products and Technologies.

The Test-SPContentDatabase cmdlet does not change any of the data or structure of the content database, but can cause load on the database while the checks are in progress, which could temporarily block use of the content database. This cmdlet should only be used against a content database that is currently under low or no usage.


Parameter Required Type Description




Specifies an existing connected Microsoft SharePoint 2010 Products content database to one of the two parameter sets in the form of a GUID or database name if it is unique.




Specifies the existing content database to test.

The type must be a valid name of a SharePoint content database; for example, SPContentDB1.




Specifies the SharePoint Web application to use to test the content database.

The type must be a valid GUID, in the form 12345678-90ab-cdef-1234-567890bcdefgh; or a valid name of SharePoint Web application (for example, MyOfficeApp1); or an instance of a valid SPWebApplication object.




Manages objects for the purpose of proper disposal. Use of objects, such as SPWeb or SPSite, can use large amounts of memory and use of these objects in Windows PowerShell scripts requires proper memory management. Using the SPAssignment object, you can assign objects to a variable and dispose of the objects after they are needed to free up memory. When SPWeb, SPSite, or SPSiteAdministration objects are used, the objects are automatically disposed of if an assignment collection or the Global parameter is not used.

When the Global parameter is used, all objects are contained in the global store. If objects are not immediately used, or disposed of by using the Stop-SPAssignment command, an out-of-memory scenario can occur.




Specifies the PSCredential object that contains the user name and password to be used for database SQL Server Authentication.

The type must be a valid PSCredential object.




Specifies the instance of the database service to use to test the specified content database.

The type must be a valid GUID, such as 12345678-90ab-cdef-1234-567890bcdefgh; a valid name of a SQL Server instance (for example, DBSvrInstance1); or an instance of a valid SPDatabaseServiceInstance object.




Returns database statistics which are row counts for tables in the content database.

----------------------------EXAMPLE 1-----------------------

Test-SPContentDatabase -name WSS_Content_DB -webapplication http://sitename

This example tests the WSS_Content_DB content database against the sitename Web application, and returns a list of issues.

----------------------------EXAMPLE 2-----------------------

$DB = Get-SPContentDatabase -site http://contoso.com
Test-SPContentDatabase $DB -showrowcounts

This example gets the content database that contains the site collection at http://contoso.com, and then tests the database against the Web application that hosts it to determine issues. Together with displaying the list of issues, by specifying the ShowRowCounts parameter, this also returns the table size metrics from the content database.