Wednesday, June 4, 2014

Get SharePoint 2013 Site Collection Size Using PowerShell

I was trying to get the usage size for one of the SharePoint personal sites, and I ended up with this script.
The script is for getting all site collections usage compared to its maximum size, sorted by size of the Site Collections and the output to a HTML file.

$a = "<style>"
$a = $a + "TABLE{border-width: 1px;border-style: solid;border-color: black;border-collapse: collapse;}"
$a = $a + "TH{border-width: 1px;padding: 1px;border-style: solid;border-color: black;}"
$a = $a + "TD{border-width: 1px;padding: 1px;border-style: solid;border-color: black;}"
$a = $a + "</style>"

Get-SPSite -Limit All | select url, @{label="Size in MB";Expression={$_.usage.storage/1MB}},@{label="Capacity";Expression={$_.Quota.StorageMaximumLevel/1MB}} | Sort-Object -Descending -Property "Size in MB" | ConvertTo-Html -Head $a -title "Site Collections sorted by size" | Set-Content sc.html


Cheers,

No comments:

Post a Comment