Skip to content

/commands/sharepoint-online/get-sposite-storage-usage

Get-SPOSite storage usage: StorageUsageCurrent and StorageQuota for every site

verified onenvironmentlocal · windows 10.0.26200 arm64 · GNU bash 5.3.15 (Git Bash)updated
tool
SharePoint Online PowerShell
versions
Microsoft.Online.SharePoint.PowerShell 16.0.27709.12000
os
windows

To see how much storage each SharePoint site uses, connect with Connect-SPOService -Url https://contoso-admin.sharepoint.com and read StorageUsageCurrent and StorageQuota from Get-SPOSite. Both are in megabytes:

powershell
Get-SPOSite -Limit All |
  Sort-Object StorageUsageCurrent -Descending |
  Select-Object Url,
    @{n='UsedGB';  e={[math]::Round($_.StorageUsageCurrent / 1024, 2)}},
    @{n='QuotaGB'; e={[math]::Round($_.StorageQuota / 1024, 2)}} |
  Format-Table -AutoSize

-Limit All is needed: without it Get-SPOSite returns at most 200 sites. Run it as a SharePoint Administrator.

The properties

The site object returned by the module has these storage properties; their names and .NET types in version 16.0.27709.12000, read offline:

powershell
Import-Module Microsoft.Online.SharePoint.PowerShell -DisableNameChecking
[Microsoft.Online.SharePoint.PowerShell.SPOSite].GetProperties() |
  Where-Object Name -in 'Url','StorageUsageCurrent','StorageQuota','StorageQuotaWarningLevel','StorageQuotaType' |
  Sort-Object Name | ForEach-Object { '{0,-25} {1}' -f $_.Name, $_.PropertyType.Name }
'Set-SPOSite -StorageQuota type: ' + (Get-Command Set-SPOSite).Parameters['StorageQuota'].ParameterType.Name

Output

StorageQuota              Int64
StorageQuotaType          String
StorageQuotaWarningLevel  Int64
StorageUsageCurrent       Int64
Url                       String
Set-SPOSite -StorageQuota type: Int64

OneDrive accounts

OneDrive sites are personal sites and are left out by default. Include them with the filter parameter set:

powershell
Get-SPOSite -IncludePersonalSite $true -Limit All -Filter "Url -like '-my.sharepoint.com/personal/'" |
  Select-Object Owner,Url,StorageUsageCurrent,StorageQuota

Change a site quota

Manual quotas apply only when the tenant's site storage management is set to Manual in the SharePoint admin center (with automatic management, setting a quota returns a generic error). Values are in MB:

powershell
# 100 GB quota, warning at 90 GB
Set-SPOSite -Identity https://contoso.sharepoint.com/sites/finance -StorageQuota 102400 -StorageQuotaWarningLevel 92160

When to use it

Use this report when the tenant storage pool is filling up, before you set manual quotas, or when a site owner reports that uploads fail because the site is full. Sorting by StorageUsageCurrent shows the few sites that hold most of the data, and comparing it with StorageQuota shows which sites are close to their limit. The same command with -IncludePersonalSite $true covers OneDrive accounts, which often account for a large share of the total.

Requirements

RequirementDetails
ModuleMicrosoft.Online.SharePoint.PowerShell (SharePoint Online Management Shell), Windows only
PowerShellWindows PowerShell 5.1; in PowerShell 7 import it with -UseWindowsPowerShell
ConnectionConnect-SPOService -Url https://TENANT-admin.sharepoint.com (the admin URL, not a site URL)
RoleSharePoint Administrator or Global Administrator in Microsoft Entra ID

Export the report

For a spreadsheet, export the same calculated columns to CSV instead of formatting them for the screen:

powershell
Get-SPOSite -Limit All |
  Select-Object Url, Template, StorageUsageCurrent, StorageQuota, StorageQuotaWarningLevel |
  Export-Csv spo-storage.csv -NoTypeInformation -Encoding UTF8

-NoTypeInformation keeps Windows PowerShell 5.1 from writing a #TYPE line at the top of the file; see Export-Csv -NoTypeInformation.

Errors you may see

MessageCause
No connection available. Use Connect-SPOService before running this CmdLet.Get-SPOSite ran before Connect-SPOService, or the session expired
Current site is not a tenant administration site.Connect-SPOService was given a site URL instead of the -admin URL
Cannot convert value ... to type "Microsoft.Online.SharePoint.PowerShell.SpoSitePipeBind"-Identity received something that is not a site URL

Fixes: No connection available, Current site is not a tenant administration site, SpoSitePipeBind conversion.

FAQ

Why does Get-SPOSite return only 200 sites?

Without -Limit, Get-SPOSite stops at 200 site collections. Add -Limit All to get every site in the tenant.

Are StorageUsageCurrent and StorageQuota in GB?

No, both are in megabytes. Divide by 1024 for gigabytes, and pass megabytes to Set-SPOSite -StorageQuota and -StorageQuotaWarningLevel.

Can I run this in PowerShell 7?

The SharePoint Online Management Shell is a Windows PowerShell module. Run it in Windows PowerShell 5.1, or in PowerShell 7 on Windows with Import-Module Microsoft.Online.SharePoint.PowerShell -UseWindowsPowerShell.

Sources