Export Test-SPContentDatabase Results to a CSV File

If you want to collect the results from Test-SPContentDatabase into a CSV file, you can do some with some additional PowerShell code.  The following will create a timestamped CSV file containing the output from Test-SPContentDatabase.

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

# enumerate all the databases in the farm
Get-SPContentDatabase | % { $databaseName = $_.Name; $_ } | Test-SPContentDatabase | % {
    # get the SPContentDatabaseTestResultObject
    $databaseTestResult = $_

    # create a hash table
    $props = @{}

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

    # 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_{0}.csv" -f (Get-Date).ToString("yyyy-MM-dd_hhmmss")) -NoTypeInformation