SharePoint Site Collection Storage Size - Quota Usage Report using PowerShell
Requirement: Wanted to get a quick storage quota report on SharePoint sites on their allocation vs used space metrics to find out underutilized sites.
Solution: PowerShell script to get SharePoint site quota report!
If you want to get used storage space for a particular site collection, use:
Get Site collection Storage assigned vs used for all site collections:
Report Output:
Note that the "Infinity" has occurred on sites with No quota assigned!
Solution: 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={$_.usage.storage/1MB}}To get storage data for all site collections, use:
Get-SPSite | Select Url, @{Label="Size";Expression={$_.usage.Storage/1MB}} | Sort-Object -Descending -Property "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:
Note that the "Infinity" has occurred on sites with No quota assigned!
Here is an another script to generate 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) }
Hi and thank you for your great scripts. Really helpful.
ReplyDeleteI have tried to use the above one but I have a problem - even though I have farm administrator rights, for all users MySites I always get 0 storage used. For my own MySite and other site-collections where I am owner I get the correct storage size, but for the users MySites. Is there a way to correct this behavior?
Thank you very much,
Marian Vulpe
Add yourself under User Policy with FULL control for MySite Web Application!
DeleteHi,
ReplyDeleteThanks for this script! It helped me to pull the data quickly.
Regards,
Rustam Shaikh
your blogs, especially powershell scripts are very useful & come in handy at several occasions. keep up the good work..Many thanks :)
ReplyDelete