Skip to content

Instantly share code, notes, and snippets.

@ciphertxt
Created November 12, 2015 15:03
Show Gist options
  • Select an option

  • Save ciphertxt/0c3872d4ae7a61539ad0 to your computer and use it in GitHub Desktop.

Select an option

Save ciphertxt/0c3872d4ae7a61539ad0 to your computer and use it in GitHub Desktop.
Runs Test-SPContentDatabase against all web applications/content databases and outputs to a CSV. From http://blogs.technet.com/b/fromthefield/archive/2013/07/29/automating-test-spcontentdatabase.aspx
Add-PSSnapin Microsoft.SharePoint.PowerShell -EA SilentlyContinue
foreach ($WebApp in (Get-SPWebApplication)) {
"Testing Web Application - " + $WebApp.Name | Write-Host -ForegroundColor Green;
foreach ($CDB in $WebApp.ContentDatabases) {
Test-SPContentDatabase -Name $CDB.Name -WebApplication $WebApp.URL -ServerInstance $CDB.Server | ConvertTo-Csv | Out-File -Encoding default -FilePath $("C:\temp\" + $CDB.Name + ".csv")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment