All scripts
Microsoft 365 848

Get-OneDriveStorageReport

Reports OneDrive storage used and quota for every user, sorted largest first, to catch accounts approaching their limit before sync starts failing.

Get-OneDriveStorageReport.ps1
<#
.SYNOPSIS
    Reports OneDrive storage usage across all users.

.DESCRIPTION
    Lists every user's OneDrive site with storage used, quota, and percent
    used, sorted largest first, so accounts closing in on their limit are
    caught before sync starts failing for that user.

.PARAMETER WarningThresholdPercent
    Percent of quota used to flag as a warning. Defaults to 90.

.EXAMPLE
    .\Get-OneDriveStorageReport.ps1

.NOTES
    Requires PnP.PowerShell connected to the SharePoint admin site.

.AUTHOR
    Shehryar Hassan
#>

param(
    [int]$WarningThresholdPercent = 90
)

$oneDriveSites = Get-PnPTenantSite -IncludeOneDriveSites -Filter "Url -like '-my.sharepoint.com/personal/'"

$report = $oneDriveSites | ForEach-Object {
    $percentUsed = if ($_.StorageQuota -gt 0) { [math]::Round(($_.StorageUsageCurrent / $_.StorageQuota) * 100, 1) } else { 0 }
    [pscustomobject]@{
        Owner       = $_.Owner
        UsedGB      = [math]::Round($_.StorageUsageCurrent / 1024, 2)
        QuotaGB     = [math]::Round($_.StorageQuota / 1024, 2)
        PercentUsed = $percentUsed
        Warning     = $percentUsed -ge $WarningThresholdPercent
    }
}

$report | Sort-Object UsedGB -Descending | Format-Table -AutoSize

Read it before you run it, and test in a safe tenant first.