One of my clients recently asked how to check the size of a specific SharePoint document library. The easiest way is through SharePoint’s Storage Metrics, which is available in the site settings. It provides the total size, %of Site Quota, etc.
In this article, I will also explain how to get the SharePoint document library size using PnP PowerShell.
Get SharePoint Library Size From SharePoint Site Settings
In the image below, you can see, under Storage Metrics, the total size and percentage of parent, as well as the percentage of Site Quota, for all system libraries and custom libraries.

Follow the steps below to get the size of a particular SharePoint document library.
1. In the SharePoint site, open the Site Contents -> Click on Site settings.

2. In Site Settings ->Under Site Collection Administration -> Open Storage Metrics.

Now, as in the intro image, it will display the storage of each library from SharePoint.
Get SharePoint Library Size Using PnP PowerShell
Let’s see how to use PnP PowerShell to retrieve the size of a SharePoint document library.
In the image below, you can see in the Terminal pane of VS Code that the size [3.65 MB] of the provided document library [Employee Travel Authorization PDF Files] is displayed.

Let’s understand the Pnp PowerShell code that returns the size of the particular SharePoint document library.
$SiteURL = "https://<tenant name>.sharepoint.com/sites/TravelAuthorization"
$LibraryName = "Employee Travel Authorization PDF Files"
$ClientID = "your clinet id"
Connect-PnPOnline -Url $SiteURL -ClientId $ClientID -Interactive
# Get the storage metric of the library
$LibraryStorage = Get-PnPFolderStorageMetric -List $LibraryName
# Show TotalSize in MB
$LibrarySizeMB = [Math]::Round($LibraryStorage.TotalSize / 1MB, 2)
Write-Host "Total Library Size: $LibrarySizeMB MB"
Here,
- $SiteURL = Provide your site url.
- $LibraryName = Provide library name.
- $ClientID = Provide the client ID.
- Get-PnPFolderStorageMetric = Allows retrieval of storage metrics for a folder in SharePoint Online, which is stored in the $LibraryStorage variable.
- [Math]:: Round($LibraryMetric.TotalSize / 1MB, 2) = It takes the total size in bytes, converts it into megabytes, and rounds it to two decimal places.
Get All SharePoint Libraries Sizes Using PnP PowerShell
In this section, we will learn how to retrieve the size of all libraries present on the SharePoint site using PnP PowerShell.
In the image below, you can observe that the TERMINAL pane returns the library names along with their sizes.

$SiteURL = "https://<tenant name>.sharepoint.com/sites/SalesDepartmentTeam"
$ClientID = "your client ID"
Connect-PnPOnline -Url $SiteURL -ClientId $ClientID -Interactive
# Get all document libraries (BaseTemplate 101 = Document Library)
$SP_Doc_Libraries = Get-PnPList | Where-Object { $_.BaseTemplate -eq 101}
# Array to store the results
$Storage_Results = @()
foreach ($Library in $SP_Doc_Libraries) {
try {
# Get storage details of the libraries
$Storagedata = Get-PnPFolderStorageMetric -List $Library.Title
$SizeMB = [Math]::Round($Storagedata.TotalSize / 1MB, 2)
$Storage_Results += [PSCustomObject]@{
"Library Name" = $Library.Title
"Size (MB)" = $SizeMB
}
}
catch {
Write-Warning "Couldn't get size for library: $($Library.Title)"
}
}
$Storage_Results | Sort-Object "Size (MB)" -Descending | Format-Table -AutoSize
Here,
- $SP_Doc_Libraries = Stores all library names from the given SharePoint site. To retrieve only libraries, we use the Where object to apply a filter that BaseTemplate -eq 101, where 101 indicates a library.
- $Storage_Results = @() Craeting an empty array.
- Within the foreach loop under the try block, we use the Get-PnPFolderStorageMetrics command to retrieve the storage information for all the libraries.
- [Math]:: Round($Metric.TotalSize / 1MB, 2) = Convert bytes to MB and round to 2 decimals.
- PSCustomObject = Creating one custom object with the properties like
- Library Name
- Size(MB)
- That object is stored in the Results array.
- To handle the errors, we’re using a catch block.
- $Storage_Results | Sort-Object “Size (MB)” -Descending | Format-Table -AutoSize = It returns the results in a table format where the size is in descending order.
This way, we can get the SharePoint document library size using PnP PowerShell.
I hope you found this article helpful!
In this article, I explain how to get the size of a SharePoint document library from site settings, as well as using PnP PowerShell. Additionally, I explained how to retrieve the sizes of all SharePoint libraries using PnP PowerShell.
Also, you make like!
- How to Get File Size Using PowerShell?
- Download All Files From A SharePoint Online Document Library Using PnP PowerShell
- Delete Files From SharePoint Document Library Using Rest API in Power Automate
- Download File From SharePoint Document Library in Power Apps

Hey! I’m Bijay Kumar, founder of SPGuides.com and a Microsoft Business Applications MVP (Power Automate, Power Apps). I launched this site in 2020 because I truly enjoy working with SharePoint, Power Platform, and SharePoint Framework (SPFx), and wanted to share that passion through step-by-step tutorials, guides, and training videos. My mission is to help you learn these technologies so you can utilize SharePoint, enhance productivity, and potentially build business solutions along the way.