Site Quota comes in handy when you wish to enforce the size limits in your SharePoint site collections. It lets you set the storage limit values and warning limit values, for better farm management.

The below script will bring forth the site quota and other related information, such as maximum storage limit, maximum storage warning, etc. for the entire farm. The output will be in CSV format.
  1. if ((Get-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue) -eq $null)
  2. {
  3. Add-PSSnapin "Microsoft.SharePoint.PowerShell"
  4. }
  5. $templates = [Microsoft.SharePoint.Administration.SPWebService]::ContentService.quotatemplates
  6. $tFound = $false
  7. $templateName = "No template found"
  8. $results = @()
  9. $sites = Get-SPSite -Limit ALL
  10. try
  11. {
  12. foreach ($site in $sites)
  13. {
  14. foreach ($qt in $templates)
  15. {
  16. if ($qt.QuotaId -eq $site.Quota.QuotaID)
  17. {
  18. $templateName = $qt.Name;
  19. $tFound = $true
  20. }
  21. }
  22. if ($tFound -eq $false)
  23. {
  24. $templateName = “No Template Applied”
  25. }
  26. $tFound=$false;
  27. $RowDetails = @{
  28. "Site URL" = $site.Url
  29. "Storage Used" = $site.Usage.Storage/1MB
  30. "Storage Available Warning" = $site.Quota.StorageWarningLevel/1MB
  31. "Storage Available Maximum" = $site.Quota.StorageMaximumLevel/1MB
  32. "Sandboxed Resource Points Warning" = $site.Quota.UserCodeWarningLevel
  33. "Sandboxed Resource Points Maximum" = $site.Quota.UserCodeMaximumLevel
  34. "Quota Name" = $templateName
  35. }
  36. $results += New-Object PSObject -Property $RowDetails
  37. $site.Dispose()
  38. }
  39. }
  40. catch
  41. {
  42. $e = $_.Exception
  43. $line = $_.InvocationInfo.ScriptLineNumber
  44. $msg = $e.Message
  45. Write-Host -ForegroundColor Red "caught exception: $e at $line"
  46. Write-Host $msg
  47. write-host "Something went wrong"
  48. }
  49. $results | Export-csv -Path C:\SiteQuotaDetailedInfo.csv -NoTypeInformation
  50. Write-Host "-------------------- Completed! -----------------------------"

And, here is a screenshot of the exported data in CSV (of course, with a little bit of styling in Excel).