Deprecated: strpos(): Passing null to parameter #1 ($haystack) of type string is deprecated in /www/collab365_296/public/wp-includes/functions.php on line 7025

Deprecated: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in /www/collab365_296/public/wp-includes/functions.php on line 2162

Deprecated: Hook imagify_allow_picture_tags_for_webp is deprecated since version 2.2! Use imagify_allow_picture_tags_for_nextgen instead. in /www/collab365_296/public/wp-includes/functions.php on line 5758
SharePoint 2013: Get Site information using PowerShell Script - Collab365
Deprecated: strstr(): Passing null to parameter #1 ($haystack) of type string is deprecated in /www/collab365_296/public/wp-includes/functions.php on line 1145

Deprecated: stripos(): Passing null to parameter #1 ($haystack) of type string is deprecated in /www/collab365_296/public/wp-includes/functions.php on line 1152

Deprecated: stripos(): Passing null to parameter #1 ($haystack) of type string is deprecated in /www/collab365_296/public/wp-includes/functions.php on line 1155

Deprecated: strpos(): Passing null to parameter #1 ($haystack) of type string is deprecated in /www/collab365_296/public/wp-includes/functions.php on line 1162

Deprecated: strpos(): Passing null to parameter #1 ($haystack) of type string is deprecated in /www/collab365_296/public/wp-includes/functions.php on line 1165

Deprecated: strstr(): Passing null to parameter #1 ($haystack) of type string is deprecated in /www/collab365_296/public/wp-includes/functions.php on line 1145

Deprecated: stripos(): Passing null to parameter #1 ($haystack) of type string is deprecated in /www/collab365_296/public/wp-includes/functions.php on line 1152

Deprecated: stripos(): Passing null to parameter #1 ($haystack) of type string is deprecated in /www/collab365_296/public/wp-includes/functions.php on line 1155

Deprecated: strpos(): Passing null to parameter #1 ($haystack) of type string is deprecated in /www/collab365_296/public/wp-includes/functions.php on line 1162

Deprecated: strpos(): Passing null to parameter #1 ($haystack) of type string is deprecated in /www/collab365_296/public/wp-includes/functions.php on line 1165

Warning: Undefined array key "url" in /www/collab365_296/public/wp-content/plugins/thrive-visual-editor/thrive-dashboard/inc/smart-site/classes/class-tvd-smart-shortcodes.php on line 85

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

(Visited 181 times, 1 visits today)

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.

Summit Bundle

Get 200+ hours of Microsoft 365 Training for 27$!

Master Office 365, Power Platform & SharePoint & Teams With 200+ Hours Of Training Videos and 108 Ebooks in the Collab365 Academy. This offer is insane and is only available for a limited period.