Here are more handy PowerShell scripts for OneDrive management in Microsoft 365.
Connect with Connect-SPOService https://tenant-admin.sharepoint.com, then run:
$OneDrives = Get-SPOSite -IncludePersonalSite $True -Limit All -Filter "Url -like '-my.sharepoint.com/personal/'"
$Result = @()
foreach ($OneDrive in $OneDrives) {
$Result += [PSCustomObject]@{
Email = $OneDrive.Owner
URL = $OneDrive.URL
QuotaGB = [Math]::Round($OneDrive.StorageQuota / 1GB, 2)
UsedGB = [Math]::Round($OneDrive.StorageUsageCurrent / 1GB, 2)
PercentUsed = [Math]::Round(($OneDrive.StorageUsageCurrent / $OneDrive.StorageQuota) * 100, 1)
}
}
$Result | Export-Csv "OneDriveUsage.csv" -NoTypeInformation
Shows quota, usage, percentage per user—export to CSV.
PnP Storage Metrics (with Last Activity)
Use PnP: Connect-PnPOnline https://tenant-admin.sharepoint.com -Interactive
$oneDrives = Get-PnPTenantSite -IncludeOneDriveSites -Filter "Url -like '-my.sharepoint.com/personal/'" -Detailed
$oneDrives | ForEach {
[PSCustomObject]@{
"Display Name" = $_.Title
Owner = $_.Owner
"Size (GB)" = [Math]::Round($_.StorageUsageCurrent / 1GB, 2)
"Quota (GB)" = [Math]::Round($_.StorageQuota / 1GB, 2)
"Last Used" = $_.LastContentModifiedDate
Status = $_.Status
}
} | Export-Csv "OneDriveMetrics.csv" -NoTypeInformation
Includes last modified date and status.
