In this post, I am going to write Powershell script to find size of a site collection using the powershell cmdlet Get-SPSite. The Get-SPSite cmdlet includes the property Usage, this property in-turn includes another property Storage, this is the actual value of current storage size of a site collection.
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue $sc = Get-SPSite http://spsvr:90 $sc.Usage.Storage
Use the below script to get size in MB or GB.
$sc = Get-SPSite http://sp01:85 $SizeinMB = [System.Math]::Round((($sc.Usage.Storage)/1MB),2) $SizeInGB = [System.Math]::Round((($sc.Usage.Storage)/1GB),2)
Get size of all site collections in SharePoint Farm
The below powershell script find and retrieves the size of all the site collections in SharePoint Farm. This command gets the storage usage in MB instead of bytes and sorted the site collections by size.
Get-SPSite | Select-Object Url, @{n="Database";e={$_.ContentDatabase.Name}}, @{n="SizeInMB";e={$_.Usage.storage/1MB}} | Sort-Object -Descending -Property "SizeInMB"
You can also export the details to csv file.
Get-SPSite | Select-Object Url, @{n="Database";e={$_.ContentDatabase.Name}}, @{n="SizeInMB";e={$_.Usage.storage/1MB}} | Export-CSV "C:\site-collections-size.csv" -NoTypeInformation -Encoding UTF8
Advertisement
great thanks! [12.03.2019]