Connect-SPOService -Url https://xxxxx-admin.sharepoint.com
$ODFBSites = Get-SPOSite -Limit All | Select Owner, Title, URL, StorageQuota, StorageUsageCurrent | Sort StorageUsageCurrent -Desc
$TotalODFBGBUsed = [Math]::Round(($ODFBSites.StorageUsageCurrent | Measure-Object -Sum).Sum /1024,2)
$Report = [System.Collections.Generic.List[Object]]::new()
ForEach ($Site in $ODFBSites) {
$ReportLine = [PSCustomObject]@{
Owner = $Site.Title
Email = $Site.Owner
URL = $Site.URL
QuotaGB = [Math]::Round($Site.StorageQuota/1024,2)
UsedGB = [Math]::Round($Site.StorageUsageCurrent/1024,2)
PercentUsed = [Math]::Round(($Site.StorageUsageCurrent/$Site.StorageQuota * 100),2) }
$Report.Add($ReportLine) }
$Report | Export-CSV -NoTypeInformation sporeport.CSV
Write-Host "Current OneDrive for Business storage consumption is" $TotalODFBGBUsed "GB. Report is in sporeport.CSV"