Testing content database before migrating to SharePoint 2013


One of the steps in the SharePoint 2013 migration process is to test the content databases to identify potential issues before migrating to the new 2013 schema. This article shows a PowerShell script to execute the validation and export the results to a CSV file. Special kudos to Joe Rodgers for the original algorithm. I modified the code a little bit to be able to pass the parameters and focus on one DB at the time.


 [Parameter(Mandatory=$true)] [string]$DBName,
 [Parameter(Mandatory=$true)] [string]$WebAppUrl

# array to store the output
$results = @()

Test-SPContentDatabase -Name $DBName -WebApplication $WebAppUrl | % {
   # get the SPContentDatabaseTestResultObject
   $databaseTestResult = $_

   # create a hash table
   $props = @{}

   # add the database name to the output
   $props.Add("DatabaseName", $DBName) 

   # dynamically add all of the SPContentDatabaseTestResult properties to the output
   $_ | Get-Member -MemberType *Property | % { 
     $props.Add($_.Name, $databaseTestResult.($_.Name)) 

   # add the hashtable to the output array
   $results += New-Object PSObject -Property $props

# dump the output to csv
$results | Export-Csv $("Test-ContentDatabaseResults_{1}_{0}.csv" -f (Get-Date).ToString("yyyy-MM-dd_hhmmss"), $DBName) -NoTypeInformation

How to use the Script

  1. Copy the above code into a file a name it “TestDB.ps1
  2. Save the file to a local directory in the SharePOint Server i.e: “c:\temp”
  3. Open SharePoint Management Shell
  4. Navigate to the script location i.e: “PS> cd c:\temp”
  5. Execute the script with the two parameters. i.e: PS> TestDB.ps1 -DBName <NameOfDatabase> -WebAppUrl <UrlOfWebApp>
  6. On successful completion, a CSV file is generated containing the DB name and the time stamp in the title i.e: Test-ContentDatabaseResults_DBName_2016-07-05_025815.csv
  7. Repeat the steps for each content DB to be upgraded


Upgrade Content Databases to SharePoint 2013

Export Test-SPContentDatabase Results to a CSV File


Author: Luis Carrazana

Skilled Senior Technology Consultant and Strategist, with 15+ of experience advising and assisting customers from small and large companies from multiple industries, including Pharma, Insurance and Financial Services. Leveraging the right technology for the right job. Passionate about Software Craftsmanship, Quality, Agile, DevOps and Cloud Computing.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s