Display SharePoint site quota information using PowerShell

Scenario: You want a list of all the sites quota on your SharePoint environment.

Solution: use the following PowerShell script (you might want to save it as “quota.ps1″ and run it from the SharePoint 2010 Management Shell

 

$t = [Microsoft.SharePoint.Administration.SPWebService]::ContentService.quotatemplates
$tFound = $false
$webApp = Get-SPWebApplication | %{$_.Sites} | Get-SPSite -Limit ALL
$webApp | fl Url, @{n=”Storage Used/1MB”;e={[int]($_.Usage.Storage/1MB)}},
@{n=”Storage Available Warning/1MB”; e={[int](($_.Quota).StorageWarningLevel/1MB)}},
@{n=”Storage Available Maximum/1MB”; e={[int](($_.Quota).StorageMaximumLevel/1MB)}},
@{n=”Sandboxed Resource Points Warning”;e={[int](($_.Quota).UserCodeWarningLevel)}},
@{n=”Sandboxed Resource Points Maximum”;e={[int](($_.Quota).UserCodeMaximumLevel)}},
@{n=”Quota Name”; e={ foreach($qt in $t){if($qt.QuotaId -eq [int](($_.Quota).QuotaID)){$qt.Name; $tFound = $true}} if($tFound -eq $false){“No Template Applied”}$tFound=$false;}} >> c:\quotaoutput.txt
if($parent) {$webApp.Dispose(); $t.Dispose()}

The results will look like:

Url                               : http://sps2010:3033
Storage Used/1MB                  : 12
Storage Available Warning/1MB     : 0
Storage Available Maximum/1MB     : 0 Sandboxed Resource Points Warning : 100
Sandboxed Resource Points Maximum : 300
Quota Name                        : No Template Applied

 

Update from June 23 2018

Since some people from Capgemini consider that my script “might work” and think it is “terrible” and “not human readable”, I thought to ease their pain and re-write it in a more “non-geeky” way: