OneDrive for Business is a crucial part of SharePoint Online, allowing users to store files in the cloud. As an Administrator, you may need to check the storage usage of OneDrive sites to ensure users are not exceeding allocated space.
This guide will show you how to:
Connect to SharePoint Online using PnP PowerShell
Retrieve OneDrive storage usage for all users
Export OneDrive storage details to a CSV file
Step 1: Install and Import PnP PowerShell
If you haven’t installed PnP PowerShell, run:
Install-Module -Name PnP.PowerShell -Scope CurrentUser -AllowClobber -Force
After installation, import the module:
Import-Module PnP.PowerShell
PnP PowerShell is ready!
Step 2: Connect to SharePoint Online
To retrieve OneDrive storage details, connect to SharePoint Online Admin Center:
$adminUrl = "https://yourtenant-admin.sharepoint.com"
Connect-PnPOnline -Url $adminUrl -Interactive
🔹 Replace “yourtenant” with your actual Microsoft 365 tenant name.
🔹 Sign in as a Global Administrator or SharePoint Admin.
Connected to SharePoint Online!
Step 3: Check OneDrive Storage Usage for All Users
To list storage usage for all OneDrive sites:
Get-PnPTenantSite -IncludeOneDriveSites | Select-Object Url, StorageUsageCurrent, StorageQuota
Output Includes:
- Url → The OneDrive site URL
- StorageUsageCurrent → Current storage used (in MB)
- StorageQuota → Total allocated storage (in MB)
OneDrive storage details retrieved successfully!
Step 4: Export OneDrive Storage Usage to CSV
To save OneDrive storage details into a CSV file for reporting:
$OneDriveStorage = Get-PnPTenantSite -IncludeOneDriveSites | Select-Object Url, StorageUsageCurrent, StorageQuota
$OneDriveStorage | Export-Csv -Path "C:\OneDriveStorageReport.csv" -NoTypeInformation
🔹 The CSV file will be saved at C:\OneDriveStorageReport.csv.
OneDrive storage usage exported to CSV successfully!
Step 5: Disconnect from SharePoint Online
Once done, disconnect the session:
Disconnect-PnPOnline
Disconnected successfully!