Little more about Test-SPContentDatabase cmdlet

Test-SPContentDatabase is a powershell cmdlet that is used to test the content database that is going to be upgraded from SharePoint 2007 to SharePoint 2010.
The syntax and details can be found here https://technet.microsoft.com/en-us/library/ff607941.aspx

On a higher level, the Test-SPContentDatabase checks or veririfies the following things:

  • Checking for Missing WebTemplates
  • Checking for Missing features
  • Checking for Orphaned sites
  • Checking for missing setup files
  • Checking for missing Webparts
  • Checking for missing Event reveiver assemblies

Lets deep dive in to what happens during the checks:

Missing WebTemplates:

For each of the language packs installed in the farm, the list of webtemplates and sitedefinitions are fetched. Then the fetched templates are compared against the templates present in the content database. The query used to fetch the list of templates present in the content database is:

SELECT Language, WebTemplate, COUNT(1) FROM Webs (NOLOCK) GROUP BY Language, WebTemplate

If there is a mismatch then the corresponding warnings like "Missing SiteDefinition" or "Missing web templates" are thrown. This also verifies for the language packs installed in the farm with the ones present in the content database and shows "Missing Language pack" warning if any.

Missing Features:

In case of missing features the list of features installed in the farm are fetched and compared with the list of features present in the content database. The query used is:

SELECT DISTINCT FeatureId, NULL, NULL, NULL FROM Features (NOLOCK) WHERE FeatureId IS NOT NULL
UNION SELECT DISTINCT tp_FeatureId, NULL, NULL, NULL From AllLists (NOLOCK) WHERE tp_FeatureId IS NOT NULL

If there is mismatch in the features listed, the "Missing Feature" warning is shown

Orphaned Sites:

In case of checking for orphan sites, first the list of all the site collections available in the content database are fetched using the query:

SELECT S.Id, '/' + W.FullUrl, S.HostHeader FROM Webs AS W JOIN Sites AS S ON S.Id = W.SiteId AND W.ParentWebId IS NULL

The list is then compared with data fetched from the configuration database. Basically it tries to find site ids that are not found in the Site map or found in the site map but associated with a different database and also checks if the database contains a site url that is already used by a different site in the same web application. If there is a mismatch, then the orphaned sites warning is shown.

Missing Setup files:

In case of missing setup files, validation is done to check for any front end files that are referenced in the content database but not installed in the farm. The query used to get the list of setup files is

SELECT SetupPath, COUNT(1) FROM AllDocs (NOLOCK) WHERE SetupPath IS NOT NULL GROUP BY SetupPath ORDER BY SetupPath

If any of the files referenced are found missing in the farm, then the missing setup files warning is shown

Missing Webparts:

The case of missing webparts is also similar to that of missing features check where the list of webpart type ids referenced in the content database is fetched and compared with the webparts installed in the farm. The query used to find the details is:

SELECT tp_WebPartTypeId, COUNT(1), tp_Assembly, tp_Class FROM AllWebParts (NOLOCK) 
WHERE tp_WebPartTypeId IS NOT NULL AND tp_SolutionId IS NULL GROUP BY tp_WebPartTypeId, tp_Assembly, tp_Class

If there is a mismatch then the missing webpart warning is shown.

Missing Event Receiver Assemblies:

The case of event receiver assemblies is also similar to that of missing features where validation is done to find event receiver assemblies that are referenced in the content database but not installed in the farm. The query to know the list of assemblies is:

SELECT DISTINCT Assembly From EventReceivers (NOLOCK) WHERE Assembly IS NOT NULL AND SolutionId IS NULL AND DataLength(Assembly)

Note: Ensure that the 'SharePoint 2010' web application against which the Test-SPCOntentDatabase cmdlet is being run has all the required custom solution packages deployed. Usually it may be the case that one forgets to install or deploy the custom solution package that is present in SP 2007 web application which leads to increased count of warnings.

Find here my other post about some details on how to fix the above warnings

Comments

  • Anonymous
    November 18, 2014
    If you want help for the SP2010 version of the Test-SPContentDatabase PowerShell command use this URL, technet.microsoft.com/.../ff607941(v=office.14).aspx, as the SP version selector on the generic help page is broken and doesn't show the option to pick the SharePoint version.