2014-08-27

I have uploaded a PowerShell Script on TechNet gallery, with that script you can get the site collection information which include Content DB details, count of current sub sites, and also size of each sub site, site collection and content DB. You can download and execute the script file using administrative rights on SharePoint Farm.

The output of file is saved in CSV format, which you can save it to any defined path.

The script contains 5 functions, the main function is GetGeneralInfo which generates all site information, it takes site URLS and output file path as parameter.

Function GetGeneralInfo($siteUrl, $OutputFile) 
{ 
#Write CSV- TAB Separated File) Header 
"Name `t Value" | out-file $OutputFile 
$ContentDB =  Get-SPContentDatabase -site $siteUrl 
$ContentDatabaseSize = [Math]::Round(($ContentDatabase.disksizerequired/1GB),2) 
"Database Name  `t $($ContentDB.Name)" | Out-File $OutputFile -Append 
"Database ID  `t $($ContentDB.ID)" | Out-File $OutputFile -Append 
"Site count `t $($ContentDB.CurrentSiteCount)" | Out-File $OutputFile -Append 
"Site count `t $($ContentDB.MaximumSiteCount)" | Out-File $OutputFile -Append 
"Can Migrate `t $($ContentDB.CanMigrate)" | Out-File $OutputFile -Append 
"Content DB Size `t $($ContentDatabaseSize) GB" | Out-File $OutputFile -Append 
"Database Servername `t $($ContentDB.Server)" | Out-File $OutputFile -Append 
"Connection String `t $($ContentDB.DatabaseConnectionString)" | Out-File $OutputFile -Append 
"Display Name `t $($ContentDB.DisplayName)" | Out-File $OutputFile -Append 
"Schema `t $($ContentDB.SchemaVersionXml)" | Out-File $OutputFile -Append 
GetWebSizes -StartWeb $siteUrl 
}

The function call is quite simple as below:

GetGeneralInfo "http://spFarm" "C:\GeneralInfo.csv"

The basic detail of the site collection is fetched from Get-SPContentDatabase class, and sub site and site collection size is fetched from remaining functions which is calculated all files in the document libraries.

If you feel any difficulty on running this script then do update me.

This script has been tested on SharePoint 2010 and SharePoint 2013

About the author 

Adnan Amin

With over 9 years of extensive experience with major expertise on SharePoint Server, .Net Platform and Microsoft BI, I am currently working as SharePoint Architect at En Pointe.

I am MCT Regional Lead for Pakistan Chapter since 2012. I am working on SharePoint for past five years and worked on different intranet/intranet solutions for private & govt. sector majorly in Gulf region, which include OOB and customized solutions.

I am a trainer, technology evangelist and also in speaks in community forums.