Configuring Site Storage Metrics using PnP PowerShell

Loading

Managing SharePoint Online storage metrics is crucial for ensuring efficient space usage, preventing quota overages, and maintaining site performance. SharePoint allocates storage based on the Microsoft 365 plan, and admins can use PnP PowerShell to monitor and configure site storage effectively.

Using PnP PowerShell, you can:
Retrieve and monitor storage usage for a site
Set storage quotas for individual sites
Automate alerts when storage limits are exceeded


Prerequisites

Before configuring Site Storage Metrics, ensure:

PnP PowerShell is installed

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

You are connected to SharePoint Online

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

You have SharePoint Admin or Global Admin permissions


Step 1: Checking Current Storage Usage

To retrieve current storage details of a SharePoint Online site:

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

Displays site information including storage usage, allocated quota, and warning level.

Example Output:

StorageQuota        : 5242880  # (In MB, i.e., 5GB)
StorageQuotaWarning : 4194304 # (In MB, i.e., 4GB)
StorageUsage : 2500000 # (Current usage in MB)

Step 2: Configuring Storage Quotas

To set storage limits for a site:

Set-PnPTenantSite -Url "https://yourtenant.sharepoint.com/sites/YourSite" -StorageQuota 10485760 -StorageQuotaWarningLevel 9437184

Sets storage quota to 10GB (10,485,760 MB) and warning level to 9GB (9,437,184 MB).

🔹 StorageQuota: Maximum allocated space (in MB).
🔹 StorageQuotaWarningLevel: Warning notification threshold (in MB).


Step 3: Automating Storage Alerts

You can automate alerts when storage usage crosses a threshold.

1️⃣ Get All Sites and Their Storage Usage

$sites = Get-PnPTenantSite
$threshold = 90 # Set warning at 90% of quota

foreach ($site in $sites) {
$usagePercentage = ($site.StorageUsage / $site.StorageQuota) * 100
if ($usagePercentage -ge $threshold) {
Write-Host "Warning: Site $($site.Url) has reached $([math]::Round($usagePercentage,2))% of its storage limit!" -ForegroundColor Yellow
}
}

Checks storage for all sites and alerts if usage exceeds 90% of the quota.


Step 4: Exporting Storage Reports to CSV

To export SharePoint storage details for all sites:

$sites = Get-PnPTenantSite | Select Url, StorageQuota, StorageQuotaWarningLevel, StorageUsage
$sites | Export-Csv -Path "C:\StorageMetricsReport.csv" -NoTypeInformation

Saves storage metrics to a CSV file for auditing and reporting.


Step 5: Enabling Auto-Quota Increase

Microsoft automatically increases storage in modern SharePoint setups. If auto-increase is disabled, you can enable it:

Set-PnPTenant -OneDriveStorageQuotaAutoIncreaseState Enabled

Ensures OneDrive and SharePoint sites receive automatic storage increases when needed.


Step 6: Deleting Unused Large Files or Libraries

If storage usage is too high, find and remove large libraries or files:

Find Large Document Libraries

Get-PnPList | Select Title, ItemCount, StorageQuota

Delete a Library (if necessary)

Remove-PnPList -Identity "Library Name" -Force

Troubleshooting Common Issues

1️⃣ Unable to Retrieve Site Information?

Ensure you are connected to SharePoint Admin Center:

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

2️⃣ Storage Quota Changes Not Applied?

Ensure your Microsoft 365 plan supports manual quota settings.
Verify with Get-PnPTenantSite that the changes were successfully applied.

Leave a Reply

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