If you manage SharePoint Online, keeping an eye on site storage is very important. In this tutorial, let’s walk through a PowerShell scripts to check SharePoint site storage size using both the SPO module and PnP PowerShell. We’ll also cover useful variations like checking all SharePoint sites, a single site, percentage used, and how quotas and limits actually work behind the scenes.
Prerequisites and Setup
Before you start, make sure a few basics are in place.
- You must be a SharePoint Administrator or Global Administrator in the tenant.
- You need the SharePoint Online Management Shell (or the Microsoft.Online.SharePoint.PowerShell module) installed.
- For PnP PowerShell, you need the PnP.PowerShell module installed.
You can install these modules using these simple commands in a regular PowerShell window (run as Administrator):
Install-Module -Name Microsoft.Online.SharePoint.PowerShell
Install-Module -Name PnP.PowerShellIf you get a prompt about an untrusted repository, type Y and press Enter to continue.
Connect to SharePoint Online using PowerShell
First, let’s connect to the SharePoint Online Admin Center using the SPO module.
Replace <tenant> with your tenant name:
# SharePoint Admin Center URL
$AdminSiteUrl = "https://<tenant>-admin.sharepoint.com"
# Connect to SharePoint Online Admin Center
Connect-SPOService -Url $AdminSiteUrlWhen you run this, you’ll get a sign‑in prompt where you can enter your admin credentials or sign in with modern authentication (MFA is supported if enabled).
If the connection fails, common reasons are:
- Wrong admin URL (make sure it ends with -admin.sharepoint.com).
- Your account is not SharePoint/Global admin.
- You’re behind a proxy or firewall blocking the connection.
Once this is connected, you can query site collections using Get-SPOSite.
Check out Get the SharePoint Site Owner Using PowerShell
Get Storage Size for a Single SharePoint Site (SPO module)
If you just want to check the storage size of one SharePoint site (for example, https://contoso.sharepoint.com/sites/Finance), you can use -Identity with Get-SPOSite.
$SiteUrl = "https://contoso.sharepoint.com/sites/Finance"
$Site = Get-SPOSite -Identity $SiteUrl
Write-Host "URL: " $Site.Url
Write-Host "Allocated (MB): " $Site.StorageQuota
Write-Host "Used (MB): " $Site.StorageUsageCurrent
Write-Host "Warning Level (MB):" $Site.StorageQuotaWarningLevelThis is essentially the same logic your current script uses, but more focused and readable. You can easily adjust this for any SharePoint Team site, Communication site, or even Microsoft 365 Group–backed site by changing the URL.
If you want a more “report‑style” output, you can create a custom object:
$Site = Get-SPOSite -Identity $SiteUrl
[PSCustomObject]@{
Url = $Site.Url
StorageQuotaMB = $Site.StorageQuota
StorageUsedMB = $Site.StorageUsageCurrent
StorageWarningLevelMB = $Site.StorageQuotaWarningLevel
}This prints a neat table in the console and is easy to export to CSV if needed.
Here is an example:
#Config Parameters
$AdminSiteURL="https://szg52-admin.sharepoint.com"
$SiteURL="https://szg52.sharepoint.com/sites/FinanceDepartment"
#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.StorageQuotaWarningLevelNote:
To get the SharePoint communication site storage quota, also include the same script, but only change the SiteURL. Then, It will get the allocated storage quota, current storage uasge and storage quota warning level.
Output:
The output values of a SharePoint site storage quota will be displayed in MB.

This way, we can get the storage size of a particular SharePoint site.
Note
The maximum storage size limit for a SharePoint site by default is 25TB. We can also set the SharePoint site storage limit.
Check out Enable Item-level Permissions in a SharePoint Document Library Using PowerShell
Get Storage Size for all SharePoint Sites (SPO module)
The quickest way to see storage usage for every SharePoint site collection is a simple Get-SPOSite command.
Get-SPOSite -Limit All |
Select Url, StorageUsageCurrent, StorageQuota, StorageQuotaWarningLevelStorageUsageCurrent– current storage used by the SharePoint site in MB.StorageQuota– allocated storage quota in MB.StorageQuotaWarningLevel– warning threshold in MB.
You can also sort by usage to quickly spot the largest SharePoint sites:
Get-SPOSite -Limit All |
Select Url, StorageUsageCurrent, StorageQuota |
Sort-Object StorageUsageCurrent -DescendingA practical improvement is to calculate the percentage used:
Get-SPOSite -Limit All |
Select Url,
StorageUsageCurrent,
StorageQuota,
@{ Name = '%Used'; Expression = {
if ($_.StorageQuota -gt 0) {
'{0:P2}' -f ($_.StorageUsageCurrent / $_.StorageQuota)
}
else {
'N/A'
}
}} |
Sort-Object StorageUsageCurrent -DescendingThis gives you a neat “%Used” column so you can quickly see which sites are close to their quota.
If you want to export this to a CSV report (for your records or for management), use:
Get-SPOSite -Limit All |
Select Url,
StorageUsageCurrent,
StorageQuota,
StorageQuotaWarningLevel |
Export-Csv -Path "C:\Reports\SPO-SiteStorageReport.csv" -NoTypeInformationCheck out Get All Microsoft 365 Group Connected SharePoint Sites using PowerShell
Understanding SharePoint Online Storage Limits
It’s helpful to understand what these numbers actually mean so you can interpret the output correctly.
At a high level:
- Each tenant gets a pool of storage (1 TB base + 10 GB per licensed user, plus any extra storage you purchase).
- All SharePoint sites share this tenant storage pool.
- A single SharePoint site cannot exceed 25 TB of storage.
A few key points:
- The values returned by
StorageUsageCurrentandStorageQuotaare in MB (megabytes). - 1024 MB is approximately 1 GB.
- Once a site reaches its quota, users may see errors or the site may behave as read‑only until space is freed or the quota is increased.
If you manage a multi‑geo tenant, you can also check storage per geo location using:
Get-SPOGeoStorageQuota -AllLocationsThis shows storage quota information per location.
Read Upload Single or Multiple Files to SharePoint with Metadata Using PnP PowerShell
Get SharePoint Site Storage using PnP PowerShell (tenant level)
PnP PowerShell is more modern and often easier to work with, especially if you’re already using it for other admin tasks.
First, connect to the SharePoint tenant or site:
$SiteUrl = "https://contoso.sharepoint.com/sites/Finance"
Connect-PnPOnline -Url $SiteUrl -InteractiveUsing -Interactive gives you a modern auth popup and works well with MFA.
To get storage details at the tenant level for a specific site, you can use Get-PnPTenantSite:
$SiteUrl = "https://contoso.sharepoint.com/sites/Finance"
Get-PnPTenantSite -Url $SiteUrl |
Select Url,
@{Label = "Allocated (GB)"; Expression = { $_.StorageMaximumLevel / 1024 }},
@{Label = "Used (GB)"; Expression = { $_.StorageUsage / 1024 }},
@{Label = "Warning (GB)"; Expression = { $_.StorageWarningLevel / 1024 }}StorageMaximumLevel– storage quota in MB at the tenant level.StorageUsage(orStorageUseddepending on version) – current usage in MB.StorageWarningLevel– warning threshold in MB.
Dividing by 1024 converts MB to GB, which is easier to understand in real‑world numbers.
To retrieve the same information for all the SharePoint sites:
Get-PnPTenantSite -IncludeOneDriveSites:$false |
Select Url,
@{Label = "Allocated (GB)"; Expression = { $_.StorageMaximumLevel / 1024 }},
@{Label = "Used (GB)"; Expression = { $_.StorageUsage / 1024 }},
@{Label = "Warning (GB)"; Expression = { $_.StorageWarningLevel / 1024 }} |
Sort-Object "Used (GB)" -DescendingThis gives you a tenant‑wide storage report of all SharePoint sites using PnP PowerShell.
Check out How to Check SharePoint Version Using PowerShell
Get Storage for the Current SharePoint Site using PnP PowerShell
If you’re already connected to a specific site using PnP, you can query its storage directly.
# Already connected with Connect-PnPOnline
$site = Get-PnPSite
[PSCustomObject]@{
Url = $site.Url
StorageQuotaMB = $site.StorageQuota
StorageUsedMB = $site.StorageUsed
}Alternatively, if you want info from the tenant perspective (which includes quota and warning levels fully), use:
$CurrentSite = Get-PnPSite
Get-PnPTenantSite -Url $CurrentSite.Url |
Select Url, StorageMaximumLevel, StorageUsage, StorageWarningLevelThis is useful when you want a script that you can run against any SharePoint site without hard‑coding URLs.
Check out PowerShell SharePoint Commands And Examples
Get SharePoint Site Collection Storage Size Using PnP PowerShell
I will show how to get the SharePoint site storage quota using PnP PowerShell.
Follow the below given steps:
1. First, we must connect the PnP PowerShell to the SharePoint site. To do that, Open Windows PowerShell ISE, paste the code below, and click the Run Script icon.
#connected site into Pnp PowerShell
Connect-PnPOnline -Url "https://szg52.sharepoint.com/sites/sunpharma" -Credentials (Get-Credential)
2. Then, it will ask for Username and Password. Click on OK.

3. To get the SharePoint storage capacity, run the below PnP PowerShell code into Windows PowerShell ISE. Click on the Run Script icon.
#Get the Site collection Storage Metrics
Get-PnPTenantSite -Url $SiteURL | Select @{Label="Allocated (GB)";Expression={$_.StorageMaximumLevel/1MB}}, @{Label="Used (GB)";Expression={$_.StorageUsage}},@{Label="Warning Level (GB)";Expression={$_.StorageWarningLevel/1MB}}
4. After that, you can check the SharePoint site storage details, such as Allocated Storage, Used Storage, and Storage Warning level, in the output window.
Refer to the image below:

Here is how to get the storage details of a particular SharePoint site using PnP PowerShell.
Check out How to Get File Modified Date using PowerShell
Get SharePoint Site Storage using PowerShell Examples
Now, let me show you some examples.
Here are some ready‑to‑use script snippets that may be will be helpful to you.
1. Get Storage Usage for all SharePoint Sites (SPO module)
# Connect to SPO admin
$AdminSiteUrl = "https://<tenant>-admin.sharepoint.com"
Connect-SPOService -Url $AdminSiteUrl
# Get storage usage for all site collections
Get-SPOSite -Limit All |
Select Url,
StorageUsageCurrent,
StorageQuota,
StorageQuotaWarningLevel,
@{ Name = '%Used'; Expression = {
if ($_.StorageQuota -gt 0) {
'{0:P2}' -f ($_.StorageUsageCurrent / $_.StorageQuota)
}
else {
'N/A'
}
}} |
Sort-Object StorageUsageCurrent -Descending2. Export site storage report to CSV (SPO module)
$AdminSiteUrl = "https://<tenant>-admin.sharepoint.com"
Connect-SPOService -Url $AdminSiteUrl
$ReportPath = "C:\Reports\SPO-SiteStorageReport.csv"
Get-SPOSite -Limit All |
Select Url,
StorageUsageCurrent,
StorageQuota,
StorageQuotaWarningLevel |
Export-Csv -Path $ReportPath -NoTypeInformation
Write-Host "Report exported to $ReportPath"3. Get storage for a single site (SPO module)
$AdminSiteUrl = "https://<tenant>-admin.sharepoint.com"
$SiteUrl = "https://contoso.sharepoint.com/sites/ProjectA"
Connect-SPOService -Url $AdminSiteUrl
$Site = Get-SPOSite -Identity $SiteUrl
[PSCustomObject]@{
Url = $Site.Url
StorageQuotaMB = $Site.StorageQuota
StorageUsedMB = $Site.StorageUsageCurrent
StorageWarningLevelMB = $Site.StorageQuotaWarningLevel
}4. Get tenant‑wide storage report with PnP PowerShell
# Connect to any site as an admin
Connect-PnPOnline -Url "https://contoso.sharepoint.com" -Interactive
# Get all SharePoint sites (excluding OneDrive if you want)
Get-PnPTenantSite -IncludeOneDriveSites:$false |
Select Url,
@{Label = "Allocated (GB)"; Expression = { $_.StorageMaximumLevel / 1024 }},
@{Label = "Used (GB)"; Expression = { $_.StorageUsage / 1024 }},
@{Label = "Warning (GB)"; Expression = { $_.StorageWarningLevel / 1024 }} |
Sort-Object "Used (GB)" -Descending5. Get storage for current site only (PnP PowerShell)
Connect-PnPOnline -Url "https://contoso.sharepoint.com/sites/Finance" -Interactive
$Site = Get-PnPSite
[PSCustomObject]@{
Url = $Site.Url
StorageQuotaMB = $Site.StorageQuota
StorageUsedMB = $Site.StorageUsed
}Conclusion
I hope you understand how to get SharePoint site storage size using PowerShell and PnP PowerShell.
You may also like the following PowerShell tutorials:
- SharePoint ULS Logs For Monitoring and Troubleshooting
- Connect-PnPOnline : The term ‘Connect-PnPOnline’ is not recognized
- Get SharePoint List Name using PowerShell

After working for more than 18 years in Microsoft technologies like SharePoint, Microsoft 365, and Power Platform (Power Apps, Power Automate, and Power BI), I thought will share my SharePoint expertise knowledge with the world. Our audiences are from the United States, Canada, the United Kingdom, Australia, New Zealand, etc. For my expertise knowledge and SharePoint tutorials, Microsoft has been awarded a Microsoft SharePoint MVP (12 times). I have also worked in companies like HP, TCS, KPIT, etc.