Managing OneDrive Quotas using PnP PowerShell

Loading

OneDrive for Business is an integral part of SharePoint Online, providing cloud storage for individual users. As a SharePoint Administrator, you may need to manage storage quotas for OneDrive sites to optimize resource allocation and prevent overuse.

In this guide, we will cover:
Connecting to SharePoint Online using PnP PowerShell
Checking the current storage quota of OneDrive sites
Updating the storage quota for OneDrive sites
Exporting OneDrive quota details to a CSV file


Step 1: Install PnP PowerShell

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

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

Once installed, import the module:

powershellCopyEditImport-Module PnP.PowerShell

PnP PowerShell is now ready!


Step 2: Connect to SharePoint Online

To manage OneDrive quotas, connect to SharePoint Online as an administrator:

$tenantAdminUrl = "https://yourtenant-admin.sharepoint.com"

Connect-PnPOnline -Url $tenantAdminUrl -Interactive

🔹 Replace “yourtenant” with your actual Microsoft 365 tenant name.
🔹 A login prompt will appear—sign in as a Global Administrator or SharePoint Admin.

Successfully connected to SharePoint Online!


Step 3: Check Current OneDrive Storage Quotas

To retrieve the storage quota details for all OneDrive sites, run:

Get-PnPTenantSite -IncludeOneDriveSites | Select-Object Url, StorageUsageCurrent, StorageQuota

This will display:

  • URL of each OneDrive site
  • Current storage usage (in MB)
  • Total storage quota allocated (in MB)

OneDrive site storage details retrieved!


Step 4: Update OneDrive Storage Quota

To increase or decrease storage quota for a specific OneDrive site:

Set-PnPTenantSite -Url "https://yourtenant-my.sharepoint.com/personal/user1_yourtenant_onmicrosoft_com" -StorageQuota 512000

🔹 Replace the URL with the specific OneDrive site URL.
🔹 The StorageQuota value is in MB (512000 MB = 500 GB).

OneDrive storage quota updated successfully!


Step 5: Apply a Default OneDrive Storage Quota

To set a default storage quota for all new OneDrive sites:

Set-SPOTenant -OneDriveStorageQuota 1024000

🔹 This sets all new OneDrive sites to have a default 1 TB storage quota (1024000 MB).

Default OneDrive quota applied successfully!


Step 6: Export OneDrive Quota Details to CSV

To save OneDrive storage details for all users into a CSV file:

$OneDriveQuota = Get-PnPTenantSite -IncludeOneDriveSites | Select-Object Url, StorageUsageCurrent, StorageQuota
$OneDriveQuota | Export-Csv -Path "C:\OneDriveQuota.csv" -NoTypeInformation

🔹 The file will be saved at C:\OneDriveQuota.csv.

OneDrive quota details exported to CSV!


Step 7: Disconnect from SharePoint Online

Once done, disconnect the session:

Disconnect-PnPOnline

Disconnected successfully!

Leave a Reply

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