This PowerShell SharePoint tutorial, we will discuss how to get SharePoint document library size using PowerShell in SharePoint 2013/2016.
Here we will see how to retrieve document library size from a particular site collection using PowerShell as well as we will get document library size from all the subsites from a site collection using PowerShell.
Get SharePoint document library size using PowerShell
Below is the PowerShell script to get document library size using PowerShell in SharePoint 2013/2016. You can run the PowerShell script using PowerShell ISE or Visual Studio Code.
$siteURL = "http://mypc/sites/MySP2016SiteCollection/"
$site = new-object Microsoft.SharePoint.SPSite($siteURL)
$web=$site.openweb()
foreach ($list in $web.Lists)
{
if($list.BaseType -eq "DocumentLibrary")
{
$listSize = 0
foreach ($item in $list.items)
{
$listSize += ($item.file).length
}
"Web Name: "+$web.Title+", Library Name: "+$list.Title+", Size: "+[Math]::Round(($listSize/1MB),2)+"MB"
}
}
Get document library size using PowerShell from SharePoint subsites
Now, we will see how to get document library size using PowerShell from site collection and subsites in SharePoint 2013/2016.
Here, I am providing a site collection URL and it will display all the document library size from all the sites and subsites in SharePoint.
$siteURL = "http://mypc/sites/MySP2016SiteCollection/"
$site = new-object Microsoft.SharePoint.SPSite($siteURL)
foreach ($web in $site.AllWebs)
{
foreach ($list in $web.Lists)
{
if($list.BaseType -eq "DocumentLibrary")
{
$listSize = 0
foreach ($item in $list.items)
{
$listSize += ($item.file).length
}
"Web Name: "+$web.Title+", Library Name: "+$list.Title+", Size: "+[Math]::Round(($listSize/1MB),2)+"MB"
}
}
}
You can run the PowerShell script and can see the output like below:

You may like following PowerShell SharePoint tutorials:
- PowerShell cannot be loaded because running scripts is disabled on this system windows 10
- PowerShell SharePoint Online: The remote server returned an error: (403) Forbidden
- Connect-PnPOnline: The ‘Connect-PnPOnline’ command was found in the module ‘SharePointPnPPowerShellOnline’
- SharePoint Online Automation: Upload Files Remotely to SharePoint Online Document Library using PowerShell
- Retrieve all list names and list guids from SharePoint online site using PowerShell
- SharePoint 2016 PowerShell Script to list all Users in Site Collection
- Insert/Add item to SharePoint Online list using PowerShell
- Delete list items created before N days using PowerShell in SharePoint Online
- Retrieve List Items Created in Last N days using PowerShell SharePoint Online
- SharePoint Online check if File exists or not in the document library using PowerShell
- How to create and remove indexed column using PowerShell in SharePoint Online/2013/2016 list or document library?
- Upload bulk documents to SharePoint 2016 document library using PowerShell
- Upload large files to SharePoint online document library using PowerShell csom
- PnP PowerShell commands for SharePoint Online Site
This SharePoint tutorial we learned how to get document library size using PowerShell in SharePoint 2013/2016.
I am Bijay a Microsoft MVP (10 times – My MVP Profile) in SharePoint and have more than 17 years of expertise in SharePoint Online Office 365, SharePoint subscription edition, and SharePoint 2019/2016/2013. Currently working in my own venture TSInfo Technologies a SharePoint development, consulting, and training company. I also run the popular SharePoint website EnjoySharePoint.com