SharePoint 2013

Applies to: SharePoint Foundation 2013, SharePoint Server 2013 Enterprise

Topic Last Modified: 2016-10-06

Tests a content database.

Test-SPContentDatabase [-Identity] <SPContentDatabasePipeBind> [-AssignmentCollection <SPAssignmentCollection>] [-DatabaseCredentials <PSCredential>] [-ExtendedCheck <SwitchParameter>] [-ServerInstance <SPDatabaseServiceInstancePipeBind>] [-ShowLocation <SwitchParameter>] [-ShowRowCounts <SwitchParameter>]
Test-SPContentDatabase -Name <String> -WebApplication <SPWebApplicationPipeBind> [-AssignmentCollection <SPAssignmentCollection>] [-DatabaseCredentials <PSCredential>] [-ExtendedCheck <SwitchParameter>] [-ServerInstance <SPDatabaseServiceInstancePipeBind>] [-ShowLocation <SwitchParameter>] [-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.

SharePoint Management Shell


Parameter Required Type Description




Specifies an existing connected SharePoint 2013 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.




Checks for inconsistent authentication modes during database-attach upgrade process.

The selected mode, claims or classic, must be the same in both versions.




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.




Specifies the locations where missing templates and features are being used within the database. Typically, reported locations are scoped within the site collections that are within the specified content database.

The use of the parameter significantly increases the time to complete the test procedure.




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

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

Test-SPContentDatabase -name "test1" -webapplication http://sitename -ServerInstance "SQL2"

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

If you are using another Database Server or an Alias for the Database server (for ex. DatabaseServer2), you must include -ServerInstance “DatabaseServer2” syntax to prevent False-Positive errors about the site already existing.

----------------------------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.