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

Adnan, a distinguished professional, boasts an impressive track record as a Microsoft MVP, having achieved this prestigious recognition for the eighth consecutive year since 2015. With an extensive career spanning over 18 years, Adnan has honed his expertise in various domains, notably excelling in SharePoint, Microsoft 365, Microsoft Teams, the .Net Platform, and Microsoft BI. Presently, he holds the esteemed position of Senior Microsoft Consultant at Olive + Goose. Notably, Adnan served as the MCT Regional Lead for the Pakistan Chapter from 2012 to 2017, showcasing his leadership and commitment to fostering growth within the tech community. His journey in the realm of SharePoint spans 14 years, during which he has undertaken diverse projects involving both intranet and internet solutions for both private and government sectors. His impact has transcended geographical boundaries, leaving a mark on projects in the United States and the Gulf region, often collaborating with Fortune 500 companies. Beyond his roles, Adnan is a dedicated educator, sharing his insights and knowledge as a trainer. He also passionately advocates for technology, frequently engaging with the community through speaking engagements in various forums. His multifaceted contributions exemplify his dedication to the tech field and his role in driving its evolution.

Leave a Reply

One reply on “SharePoint 2013: Get Site information using PowerShell Script”

  • August 23, 2014 at 10:35 pm

    It’s really a nice useful item of information. I’m satisfied which you contributed this useful info with us. Please remain you up to date this way. Many thanks for sharing.