You want to get an overview of the storage usage of all site collections in your tenant, similar to what you can see in the “SharePoint Administration” section in Office 365. But as you may have hundreds of site collections, or as you want to pass on that information to someone else, you want to extract this information into a spreadsheet


$cred = Get-Credential
Connect-PnPOnline -Url "" -Credentials $cred
$sites = Get-PnPTenantSite -Detailed | select Url, StorageUsage, StorageMaximumLevel, @{label="Usage in %";Expression={[math]::Round($_.StorageUsage*100/$_.StorageMaximumLevel,2)}}
$sites | Export-Csv C:\SiteStorage.csv

Code on GitHub


Here is a sample output:

UrlStorageUsageStorageMaximumLevelUsage in %

Note: StorageUsage and StorageMaximumLevel are shown in MB

10 thoughts on “Office 365 Advent Calendar – 02 Retrieving SharePoint Online Site Collection Sizes”

    1. Hi Jan, I’m testing it. Had a quick check if there are any limits in the code, but it should return all. Interestingly, all my sites are currently reported as 0 bytes large, so maybe there are a few other issues on the backend

    2. Good catch! The CSOM cmdlets actually need to be improved, as the underlying code only retrieves 300 site collections at one time. I’ll open an issue and will see if I can code the fix myself. Will post an update here once done

    1. Check, for ‘normal’ site collections this works perfectly! However, seems when adding the -IncludeOneDriveSites parameter, only a subset of the personal sites is returned.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.