How to Get SharePoint Site Storage Size Using PowerShell?

I was working recently with PowerShell, where I needed to get the size of a SharePoint site.

With PowerShell, we can easily get the storage quota, current storage usage, storage quota warning level, and maximum storage level of a particular SharePoint site (Team or Communication site).

I will explain how to get SharePoint site storage size using PowerShell in this tutorial.

Additionally, we will see how to get SharePoint site collection storage quota using PnP PowerShell.

How to Get SharePoint Site Storage Size Using PowerShell

I will show you how to use PowerShell to get the SharePoint site size, storage used, and Maximum storage level.

Follow the below-mentioned steps:

1. On your system, search for WindowsPowerShell ISE. Click on Open.

Use PowerShell to get the SharePoint site storage size

2. First, we need to connect SharePoint Online to PowerShell. Follow the below-given code and run the code. Click on Run-Script icon.

Connect-SPOService -Url https://szg52-admin.sharepoint.com/ -Credential LidiaH@szg52.onmicrosoft.com

Replace the SharePoint tenant name and user credentials.

PowerShell get SharePoint site size

3. After that, it will ask for user password, and click OK.

Get SharePoint site size PowerShell

Now, PowerShell has connected to SharePoint Online with the particular tenant.

4. To get the size of a SharePoint site collection, run the below cmdlet in PowerShell. By giving this cmdlet, it will retrieve the SharePoint site size along with URL, Owner, Storage quota, etc, as shown in the image below:

Get-SPOSite

Click on the Run Script.

How to get SharePoint site Storage Quota using PowerShell

Output:

It will display all the SharePoint Site storage quotas in MB, as shown below image:

PowerShell check SharePoint site size

6. To get the storage capacity of a single SharePoint site, write down the code below and run it.

For this, you must provide the specific SharePoint AdminSiteURL and Site URL.

#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.StorageQuotaWarningLevel

Note:

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.
Get SharePoint site size with PowerShell

Output:

The output values of a SharePoint site storage quota will be displayed in MB.

How to check SharePoint site size PowerShell

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.

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)
Use PowerShell to get SharePoint site storage usage

2. Then, it will ask for Username and Password. Click on OK.

SharePoint Online get SPOSite size using PowerShell

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}}
SharePoint Online get SPOSite size with PowerShell

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:

How to get a SharePoint Online storage size in PowerShell

Here is how to get the storage details of a particular SharePoint site using PnP PowerShell.

Conclusion

Hope this article helped you to understand how to get SharePoint site storage size using PowerShell and PnP PowerShell.

Moreover, you may like some more PowerShell articles: