Get Content Database Size

In SharePoint 2010 or 2007 I wasn’t able to find the size of the Content Databases.  For some reason I thought it was displayed in Central Administration, wrong.

Log into one of your SharePoint servers.
Open PowerShell and paste the below code into the PowerShell window.
Run.

[Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint") | out-null
$prop_Name = [Microsoft.SharePoint.Administration.SPContentDatabase].GetProperty("Name")
$prop_DiskSizeRequired = [Microsoft.SharePoint.Administration.SPContentDatabase].GetProperty("DiskSizeRequired")
$prop_Sites = [Microsoft.SharePoint.Administration.SPContentDatabase].GetProperty("Sites")
[Microsoft.SharePoint.Administration.SPFarm]::Local.Services |? {
$_.GetType().FullName -eq "Microsoft.SharePoint.Administration.SPWebService"
} |% {
$_.WebApplications |% {
$_.Name
$_.ContentDatabases |% {
$prop_Name.GetValue($_, $null)
$prop_DiskSizeRequired.GetValue($_, $null) / 1GB
}
}
}

The output will be:
Web App
Content Database Name
Content Database Size in Gigs.

You can change the output displayed size to MB by updating:
$prop_DiskSizeRequired.GetValue($_, $null) / 1GB
$prop_DiskSizeRequired.GetValue($_, $null) / 1MB

Leave a Reply

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