Some days ago I got a job to collect and create report from a subsites size of site collection. I found several article which says the information can be collected from folder and subfolder files and their versioning size. However I wrote the script it did not convinced me about the result, because there is differential of the site collection size. After some of searching I found a solution on the codeplex.com (SPUsedSpaceInfo) which gave me the best direction and I found the best method (spsite.storagemanagementinformation) in the source code for my script in PowerShell .
How it works?
param ( [string]$Url = "", [boolean]$Export = $false ) [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint") $Site = New-Object Microsoft.SharePoint.SPSite($Url) $ListStorageInformation = $Site.StorageManagementInformation("List","Increasing","Size",0) $DocumentLibraryStorageInformation = $Site.StorageManagementInformation("DocumentLibrary","Increasing","Size",0) $DocumentStorageInformation = $Site.StorageManagementInformation("Document","Increasing","Size",0) "Total size of List: {0:N2} MB" -f (($ListStorageInformation | Measure-Object -Property Size -Sum).Sum/1MB) "Total size of DocumentLibrary: {0:N2} MB" -f (($DocumentLibraryStorageInformation | Measure-Object -Property Size -Sum).Sum/1MB) "Total size of Document: {0:N2} MB" -f (($DocumentStorageInformation | Measure-Object -Property Size -Sum).Sum/1MB) If ($Export -eq $true) { $Path = (Get-Location).Path + "\" + "{0:ddMMyyHHmm}_" -f (Get-Date) + ($site.RootWeb -Replace " ","_") + "_List.csv" "Exporting all List Storage Information here: $Path" $ListStorageInformation | Select Directory, Title, Size, Count | Export-Csv -Path $Path -Delimiter ";" $Path = (Get-Location).Path + "\" + "{0:ddMMyyHHmm}_" -f (Get-Date) + ($site.RootWeb -Replace " ","_") + "_DocumentLibrary.csv" "Exporting all DocumentLibrary Storage Information here: $Path" $DocumentLibraryStorageInformation | Select Directory, Title, Size, Count | Export-Csv -Path $Path -Delimiter ";" $Path = (Get-Location).Path + "\" + "{0:ddMMyyHHmm}_" -f (Get-Date) + ($site.RootWeb -Replace " ","_") + "_Document.csv" "Exporting all DocumentLibrary Storage Information here: $Path" $DocumentStorageInformation | Select Directory, LeafName, TotalSize | Export-Csv -Path $Path -Delimiter ";" }
Collect total storage information per List, Document Library and Document:
.\Get-SPSiteStorageInformation -Url
Collect storage information and export it into a simple report file in .csv format:
.\Get-SPSiteStorageInformation -Url -Export $true