Requirement: Wanted to get a quick storage quota report on SharePoint sites on their allocation vs used space metrics to find out underutilized sites.

PowerShell script to get SharePoint site quota report

If you want to get used storage space for a particular site collection, use:

Get-SPSite http://site-collection=url | select @{label="Size in MB";Expression={$}}

To get storage data for all site collections, use:

Get-SPSite | Select Url, @{Label="Size";Expression={$_.usage.Storage/1MB}} | Sort-Object -Descending -Property "Size"
sharepoint powershell get site collection size

Get Site collection Storage assigned vs used for all site collections:

Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

Get-SPSite | Select URL,`
@{Name="Site Owner"; Expression={$_.Owner.Email}},`
@{Name="Quota Assigned"; Expression={"{0:N2} MB" -f ($_.Quota.StorageMaximumLevel/1MB)} } ,`
@{Name="Storage Used"; Expression={"{0:N2} MB" -f ($_.Usage.Storage/1MB)}},`
@{Name="Percentage Used"; Expression={"{0:P2}" -f (   ($_.Usage.Storage/1MB) / ($_.Quota.StorageMaximumLevel/1MB ))}}`
| Out-GridView -Title " Quota Report"

Report Output:

SharePoint Site Collection Quota Usage Report

Note that the “Infinity” has occurred on sites with No quota assigned!

Here is another script to generate a Storage Quota report:

Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

#Get all available Quota Templates
$QuotaTemplates = [Microsoft.SharePoint.Administration.SPWebService]::ContentService.QuotaTemplates 
[email protected]{} #Hash Array to Hold: Quota ID & Name
$QuotaTemplates | ForEach-Object { $QuotaHash.Add($_.QuotaID, $_.Name) } 

#Get All Site collections Quota
Get-SPWebApplication | Get-SPSite -Limit "All" |  ForEach-Object { Write-host $_.RootWeb.URL". Quota Assigned : "  $QuotaHash.Get_Item($_.Quota.QuotaID) }

Source link