SharePoint Content Database Report

In case you have a solution that automatically generates lots of sharepoint sites, you might want to keep an eye on the number of sites per database. Here is one simple script that requires no maintenance and can be triggered by the task scheduler or your monitoring system.


Add-PSSnapin microsoft.sharepoint.powershell

$ScriptLocation = "C:\Scripts\ScheduledTasks\ContentDBReport"

$smtpserver = "<SMTPServerIPAddress>"
$Subject = "SharePoint Content Database Report"
$Body = "SharePoint Content Database Report"
$From = "$"
$MailingList = Get-Content $ScriptLocation\MailingList.txt

$Head = "<style>td { text-align:right }</style>"
$Body = Get-SPContentDatabase  | select @{n="Content Database Name";e={$}},maximumsitecount,currentsitecount,@{n="DiskSizeRequiredForBackup(GB)";e={[math]::Round(($($_.DiskSizeRequired)/1GB),0)}} | ConvertTo-Html -Head $Head

Send-MailMessage -From $From -To $MailingList -Subject $Subject -SmtpServer $smtpserver -BodyAsHtml "$Body"

The script will send the report via e-mail.

Leave a Reply

Your email address will not be published. Required fields are marked *