Setting Site Collection Quotas with PnP PowerShell

Loading

Managing storage quotas for SharePoint Online Site Collections is crucial to ensure efficient use of storage resources. Using PnP PowerShell, you can set storage limits and warning levels for site collections.

This guide will walk you through:
Understanding Site Collection Quotas
Checking the Current Quota
Setting a New Storage Quota
Adjusting Quota Warning Levels


Prerequisites

Before executing the commands, ensure that you have:

SharePoint Admin or Global Admin permissions
PnP PowerShell module installed
Connected to SharePoint Online


Step 1: Install and Import PnP PowerShell Module

If you haven’t installed PnP PowerShell, install it using:

Install-Module -Name PnP.PowerShell -Scope CurrentUser -AllowClobber -Force

Then, import the module:

Import-Module PnP.PowerShell

Step 2: Connect to SharePoint Online

To manage site collection quotas, connect to SharePoint Online as an Admin:

Connect-PnPOnline -Url "https://yourtenant-admin.sharepoint.com" -Interactive

🔹 Replace "yourtenant" with your SharePoint tenant name.
🔹 The -Interactive flag prompts for authentication.

For App-based authentication, use:

Connect-PnPOnline -Url "https://yourtenant-admin.sharepoint.com" -ClientId "Your-App-Client-ID" -Tenant "yourtenant.onmicrosoft.com" -CertificatePath "Path\To\Certificate.pfx"

Step 3: Check Current Site Collection Quota

To view the current storage quota of a site collection, use:

Get-PnPTenantSite -Url "https://yourtenant.sharepoint.com/sites/YourSite"

This retrieves all properties, including Storage Quota (MB) and Storage Warning Level (MB).

If you only want to see storage-related information, use:

(Get-PnPTenantSite -Url "https://yourtenant.sharepoint.com/sites/YourSite").StorageQuota

or

(Get-PnPTenantSite -Url "https://yourtenant.sharepoint.com/sites/YourSite").StorageQuotaWarningLevel

Step 4: Set Site Collection Quota

To set a new storage quota for a site collection, use:

Set-PnPTenantSite -Url "https://yourtenant.sharepoint.com/sites/YourSite" -StorageQuota 50000

🔹 This sets the storage quota to 50 GB (50,000 MB).
🔹 Replace 50000 with the required quota in MB.


Step 5: Set a Storage Warning Level

To set a storage warning level, use:

Set-PnPTenantSite -Url "https://yourtenant.sharepoint.com/sites/YourSite" -StorageQuotaWarningLevel 45000

🔹 This sets the warning threshold to 45 GB (45,000 MB).
🔹 Replace 45000 with your preferred warning level in MB.

📌 Best Practice: Always set the warning level slightly below the quota limit to get alerts before running out of space.


Step 6: Verify the Updated Quota

After setting the quota, verify the changes using:

Get-PnPTenantSite -Url "https://yourtenant.sharepoint.com/sites/YourSite"

Check the values for StorageQuota and StorageQuotaWarningLevel to ensure they reflect the new limits.


Step 7: Disconnect PowerShell Session

Once the task is complete, disconnect the session:

Disconnect-PnPOnline

This prevents unauthorized access and enhances security.


Common Errors & Troubleshooting

ErrorPossible CauseSolution
Access DeniedInsufficient permissionsEnsure you are a SharePoint Admin or Global Admin
Command not recognizedPnP PowerShell module missingRun Install-Module -Name PnP.PowerShell
Cannot connect to SharePoint OnlineAuthentication issuesUse -Interactive login mode
Quota not appliedValue is too highEnsure the quota does not exceed the total available storage

Leave a Reply

Your email address will not be published. Required fields are marked *