Export OneDrive for Business Users Storage Report using Powershell

In this post, I am going to share Powershell script to find and export current storage size used by every OneDrive users, maximum storage quota and warning size of all OneDrive sites to CSV file. We can easily find OneDrive for Business (ODFB) sites storage details using SharePoint management powershell cmdlet Get-SPOSite.

Before proceed, Install and Connect SharePoint Online PowerShell Module. Run the below commands after replacing your SPO Admin site url to connect SPO Online service.

$AdminSiteURL="https://<your tenant name>-admin.sharepoint.com"
#Connect to SharePoint Online Admin Site
Connect-SPOService -Url $AdminSiteURL

The below command retrieves all personal sites and how much storage space (in MB) used by OneDrive users.

Get-SPOSite -IncludePersonalSite $true -Limit All -Filter "Url -like '-my.sharepoint.com/personal/'" |
Select Owner, StorageUsageCurrent, Url

Export OneDrive for Business users storage size report to CSV

The below powershell script get and export all personal sites and storage details to csv file.

$Result=@()
#Get all OneDrive for Business sites
$oneDriveSites = Get-SPOSite -IncludePersonalSite $true -Limit All -Filter "Url -like '-my.sharepoint.com/personal/'"
$oneDriveSites | ForEach-Object {
$site = $_
$Result += New-Object PSObject -property @{ 
UserName = $site.Owner
Size_inMB = $site.StorageUsageCurrent
StorageQuota_inGB = $site.StorageQuota/1024
WarningSize_inGB =  $site.StorageQuotaWarningLevel/1024
OneDriveSiteUrl = $site.URL
}
}
$Result | Select UserName, Size_inMB, StorageQuota_inGB, WarningSize_inGB, OneDriveSiteUrl |
Export-CSV "C:\OneDrive-for-Business-Size-Report.csv" -NoTypeInformation -Encoding UTF8

CSV output of OneDrive for Business (ODFB) users storage report:

Export OneDrive Users Current Storage Size Report using Powershell

Advertisement

Leave a Comment