SharePoint Online: Get Site Collection Storage Size – Quota Usage Report using PowerShell

Requirement: Generate a report to analyze all SharePoint Online Site collection storage consumption.

Are you looking for a way to find the storage usage for your site collections in SharePoint Online? In this blog post, we will show you how to gather storage details of your site collection and generate a report that displays the storage consumption for all site collections in your SharePoint Online tenant.

This post will show you three ways to find the size of your SharePoint Online site:

  1. Find the site collection size from the SharePoint Online Admin center
  2. Get the size of a site collection from the “Storage Metrics” page of the site
  3. Use PowerShell to get the size of your SharePoint Online site

How to Get the Storage Metrics of a SharePoint Online Site Collection?

How to check site collection size in SharePoint Online? To find the storage details of a site collection through the web browser interface, Go to:

  1. Browse to your site collection >> Click on the Settings gear >> Site information >> and then select “View All Site Settings”.
  2. In the “Site Settings” page, under “Site Collection Administration”, click on Storage Metrics.
    get sharepoint online site collection storage metrics

This page gives SharePoint site collection storage details along with the breakdown of all sub-sites, document libraries, folders, files, and their sizes. This information can be helpful when trying to identify if your site collection is using too much storage space and needs to be cleaned up. As a side note, Recycle Bin files also count towards your storage quota. Emptying the Recycle Bin will free up that space.

You can also use SharePoint Designer to find the total storage used by a site. Open the site collection with SharePoint Designer and on the homepage under “Site Information” section, You’ll find the “Total Storage Used”!

Get Storage Usage of All Sites in SharePoint Online Admin Center:

Similarly, to check the storage usage of all site collections in SharePoint Online,

  1. Login to SharePoint Online Admin Center: https://<tenant>-admin.sharepoint.com
  2. Expand Sites >> Active Sites. This page gives you a list of all sites in the tenant, along with the storage consumption of each site and the total storage usage on the entire tenant. You can export this data to CSV as well by clicking on the “Export” link.
    check sharepoint online storage usage
How much storage is included with SharePoint Online?
The Total storage space allocated to your SharePoint Online tenant depends on your subscription plan and number of licenses. You have total storage of 1 TB plus 10 GB per-user license of any plan you purchased. You can buy extra file storage add-on to your Microsoft 365.

SharePoint Online: Get Site Collection Size using PowerShell

Let’s use the PowerShell script to get allocated storage size, used, and warning level metrics. To get the size of a SharePoint Online site collection, you can use the Get-SPOSite cmdlet in PowerShell. This cmdlet retrieves the site size along with other information about the site collection, such as the URL, owner, storage quota, etc. This script gets storage info for a single site collection using PowerShell:

#Config Parameters
$AdminSiteURL="https://crescent-admin.sharepoint.com"
$SiteURL="https://crescent.sharepoint.com/sites/Ops"

#Get Credentials to connect to SharePoint Admin Center
$Cred = Get-Credential

#Connect to SharePoint Online Admin Center
Connect-SPOService -Url $AdminSiteURL -Credential $Cred

#Get the Site collection
$Site = Get-SPOSite $SiteURL

#powershell to get sharepoint online site size
Write-Host "Allocated:"$Site.StorageQuota
Write-Host "Used:"$Site.StorageUsageCurrent
Write-Host "Warning Level:"$Site.StorageQuotaWarningLevel

This PowerShell retrieves SharePoint Online site collection quota in MBs.

SharePoint Online: Site Collection Size Report using PowerShell

How to get storage quota in SharePoint Online using PowerShell? This PowerShell script gets storage details such as the Total Size allocated and Consumption of all site collections in SharePoint Online.

#Config Parameters
$AdminSiteURL="https://crescent-admin.sharepoint.com"
$ReportOutput="C:\Temp\SPOStorage.csv"

#Get Credentials to connect to SharePoint Admin Center
$Cred = Get-Credential

#Connect to SharePoint Online Admin Center
Connect-SPOService -Url $AdminSiteURL -Credential $Cred

#Get all Site collections
$SiteCollections = Get-SPOSite -Limit All
Write-Host "Total Number of Site collections Found:"$SiteCollections.count -f Yellow

#Array to store Result
$ResultSet = @()

Foreach($Site in $SiteCollections)
{
    Write-Host "Processing Site Collection :"$Site.URL -f Yellow
    #Send the Result to CSV 
    $Result = new-object PSObject
    $Result| add-member -membertype NoteProperty -name "SiteURL" -Value $Site.URL
    $Result | add-member -membertype NoteProperty -name "Allocated" -Value $Site.StorageQuota
    $Result | add-member -membertype NoteProperty -name "Used" -Value $Site.StorageUsageCurrent
    $Result | add-member -membertype NoteProperty -name "Warning Level" -Value  $site.StorageQuotaWarningLevel
    $ResultSet += $Result
}

#Export Result to csv file
$ResultSet |  Export-Csv $ReportOutput -notypeinformation

Write-Host "Site Quota Report Generated Successfully!" -f Green

Here is the CSV file generated by the script to give an overview of the storage usage of all site collections in your tenant:

SharePoint Online site collection storage quota report

PowerShell to Get Site Collection Size in SharePoint Online: 

Other than SharePoint Online Management Shell, You can also use CSOM way as an alternate to retrieve storage size metrics of a site collection.

#Load SharePoint CSOM Assemblies
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll"
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"

$SiteURL="https://crescent.sharepoint.com"

#Get Credentials to connect
$Cred= Get-Credential
$Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Cred.Username, $Cred.Password)

#Setup the context
$Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL)
$Ctx.Credentials = $Credentials
$Site = $Ctx.Site
$Ctx.Load($Site)

#Get Storage Details
$Site.Retrieve("Usage")
$Ctx.ExecuteQuery()
$Site.Usage.Storage

Here is another post to get OneDrive site collections storage metrics: Get OneDrive Site Collection Storage Quota Size using PowerShell

SharePoint Online Site Collection size limit:
By default, the maximum storage size limit for a site is 25 TB. However, you can set SharePoint storage limits manually by following these steps. Navigate to the SharePoint admin center and click Settings. Click Site storage limits on the Settings page and switch to Manual. More info: How to Set Storage Limits in SharePoint Online

Get Storage Quota in SharePoint Online with PnP PowerShell

Let’s check SharePoint Online storage using PowerShell and get storage allocated usage and warning level metrics of the storage quota of a SharePoint Online site collection using PnP PowerShell.

#Set Variables
$SiteURL = "https://crescent.sharepoint.com"

#Connect to PnP Online
Connect-PnPOnline -Url $SiteURL -Credentials (Get-Credential)

#Get the Site collection Storage Metrics
Get-PnPTenantSite -Url $SiteURL | Select @{Label="Allocated (GB)";Expression={$_.StorageMaximumLevel/1MB}}, @{Label="Used (MB)";Expression={$_.StorageUsage}},@{Label="Warning Level (GB)";Expression={$_.StorageWarningLevel/1MB}}

Similarly, to generate a site usage report for all sites in the tenant, use:

#Parameters
$AdminCenterURL = "https://crescent-admin.sharepoint.com"
$CSVPath = "C:\Temp\SiteUsageRpt.csv"

Try {
    #Connect to Admin Center   
    Connect-PnPOnline -Url $AdminCenterURL -Interactive
 
    #Get all site usage details
    $Sites = Get-PnPTenantSite  -Detailed | Select *

    $SiteUsageData = @()
    ForEach ($Site in $Sites)
    {
        #Collect site data
        $SiteUsageData += New-Object PSObject -Property ([ordered]@{               
                'Title'                    = $Site.Title
                'URL'                      = $Site.Url
                'Description'              = $Site.Description                    
                'Owner'                    = $Site.OwnerName
                'Storage Quota'            = $Site.StorageQuota
                'Storage MaximumLevel'     = $Site.StorageMaximumLevel 
                'Storage Usage Current'    = $Site.StorageUsageCurrent
                'Resource Quota'           = $Site.ResourceQuota
                'Resource Quota Warning'   = $Site.ResourceQuotaWarningLevel
                'Resource Usage Average'   = $Site.ResourceUsageAverage
                'Resource Usage Current'   = $Site.ResourceUsageCurrent
                'Template'                 = $Site.Template
                'Sharing Capability'       = $Site.SharingCapability
                'Lock Status'              = $Site.LockState
                'Last Modified Date'       = $Site.LastContentModifiedDate
                'Subsites Count'           = $Site.WebsCount
            })
    }
    $SiteUsageData
    #Export Site Usage Data to CSV
    $SiteUsageData | Export-Csv $CSVPath -NoTypeInformation
    Write-Host "Site Usage Report Generated Successfully!" -ForegroundColor Green
}
Catch {
    Write-Host -ForegroundColor Red "Error generating site usage report:" $_.Exception.Message
}

If you need to retrieve the size of a subsite in SharePoint Online, refer: Get SharePoint Online Subsite Size using PowerShell

How do I see the size of a folder in SharePoint Online?

Navigate to the site >> Click on Settings gear >> Site Settings >> Click on the “Storage Metrics” link under “Site Collection Administration”. On the storage metrics page, navigate to the location where the target folder exists. Look at the “Total size” column to find the size of each folder and file (including version history size) in your SharePoint site.
To see the size of a folder in SharePoint Online, refer: How to check folder size in SharePoint Online?

How do I increase my SharePoint Online storage limit?

By default, SharePoint Online site storage allocation is automatically managed from the storage pool. If it’s set to manual, Here is how to increase the storage limit: Login to Admin Center >> Select the site >> click on the “Storage” button in the command bar. In the Edit storage limit, Enter the “Maximum storage for this site”. Hit save once done.
More info: How to increase storage limit of a SharePoint Online site?

How do I find the size of a SharePoint Online Library?

To get the size of a document library in SharePoint Online, Login to your SharePoint Online site >> Click on Settings >> Site Settings >> Click on the “Storage Metrics” link. The storage size of your document library is under the “Total Size” column. You can also use PowerShell to obtain the document library size.
More info: Check SharePoint Online document library size

What is the maximum file size that is supported in the SharePoint Online library?

250 GB!

How do I free up space on SharePoint Online?

To clean up the SharePoint Online site, look at the files in the first and second-stage recycle bins, Multiple versions of files, and files that are kept in the “Preservation Hold Library” based on a retention policy.

Salaudeen Rajack

Salaudeen Rajack - Information Technology Expert with Two-decades of hands-on experience, specializing in SharePoint, PowerShell, Microsoft 365, and related products. He has held various positions including SharePoint Architect, Administrator, Developer and consultant, has helped many organizations to implement and optimize SharePoint solutions. Known for his deep technical expertise, He's passionate about sharing the knowledge and insights to help others, through the real-world articles!

8 thoughts on “SharePoint Online: Get Site Collection Storage Size – Quota Usage Report using PowerShell

  • A great Blog, thank you for your effort you are putting on it _/\_
    Can you add the PrimarySmtpAddress of the owner in powershell script report.
    Thank you.

    Reply
  • Hi! Can we list the storage of root site? I have the following sites:
    nameofcompany.sharepoint.com/XXX

    How can I get the storage for this collection site?
    I can see the storage metric with used storage… But I can’t get it from powershell.

    Regards,

    Reply
    • Storage quotas are scoped at the site collection level (Not subsite!). So, You can get it only for site collection (However, You can drill down to subsite storage quota from the top-level site).

      Reply
  • Can we get the yellow banner on SharePoint Online Sites whenever the site is reaching the site storage limit ?

    The same banner which we used to get on the SharePoint On-Prem Sites.

    We are not getting the option on the Mordern SPO Sites and cannot make them classic.

    Reply
  • Hi, thanks for the above. Is there any way I could see the site’s dumpster size using powershell?

    Reply
  • another great post, thanks for your work!

    I wonder if there any way to know how much data is allocated for my tenant?(using my licenses plus extras purchased)
    How much data I use across whole tenant (I assume I have to add sizes of all sites, right?)
    and if I’m over the limit, how much then?

    All the posts I can find tell how much data particular SITE uses, but how much MS provides my tenant is something I can’t find. (‘sometimes’ it can be viewed in SP Admin portal but that changed recently for me to something like ‘0.00 MB available of XX.YY TB’)

    thanks in advance!

    Reply
    • You can login to SharePoint Online Admin Center: at https://YourTenant-admin.sharepoint.com
      Expand Sites >> Active Sites. This page gives you a list of all sites in the tenant, along with the storage consumption of each site and the total storage usage on the entire tenant. (It takes a while to update the stats though!).

      Reply

Leave a Reply

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