Get-Set OneDrive Site Collection Storage Quota Size using PowerShell
Get OneDrive Site Collection Storage Quota Information
Office 365 comes with 1 TB of storage per user in OneDrive for Business. You can use this space to store your documents, photos, and other files. It can be helpful to keep track of the storage consumption to ensure the most effective use of OneDrive sites. To get the storage quota data for a particular OneDrive site, use this PowerShell cmdlet in SharePoint Online Management Shell:
Get-SPOSite -Identity "https://crescent-my.sharepoint.com/personal/salaudeen_crescent_com"
This gets you the currently allocated storage quota data for a single site collection.
Get Storage Quota Details of All OneDrive Site collections
How about generating a report on OneDrive for Business storage consumption for all sites? Use this script in SharePoint Online Management Shell:
$AdminSiteURL="https://crescent-admin.sharepoint.com"
#Get Credentials to connect to the SharePoint Admin Center
$Cred = Get-Credential
#Connect to SharePoint Online Admin Center
Connect-SPOService -Url $AdminSiteURL -credential $Cred
#Get all Personal Site collections and export to a Text file
$OneDriveSites = Get-SPOSite -Template "SPSPERS" -Limit ALL -includepersonalsite $True
$Result=@()
# Get storage quota of each site
Foreach($Site in $OneDriveSites)
{
$Result += New-Object PSObject -property @{
URL = $Site.URL
Owner= $Site.Owner
Size_inMB = $Site.StorageUsageCurrent
StorageQuota_inGB = $Site.StorageQuota/1024
}
}
$Result | Format-Table
#Export the data to CSV
$Result | Export-Csv "C:\Temp\OneDrive.csv" -NoTypeInformation
This script produces a nice CSV report below and gives how much storage OneDrive sites are consuming.
How to Set Storage Quota for OneDrive Site Collection?
By default, OneDrive site collections in Office 365 come with a 1 TB storage quota. You may want to either increase or decrease the storage allocation in some situations. Say, you want to increase the storage quota for a particular OneDrive site collection to 2 TB:
Set-SPOSite -Identity "https://crescent-my.sharepoint.com/personal/salaudeen_crescent_com" -StorageQuota 2097152
Similarly, the User’s OneDrive storage quota can be reset to the default OneDrive storage quota
Set-SPOSite -Identity "https://crescent-my.sharepoint.com/personal/salaudeen_crescent_com" -StorageQuotaReset
You can change the OneDrive storage allocation for a user from Microsoft 365 Admin center as well: How to Increase OneDrive for Business Storage Quota for a User?
Set-SPOTenant -OneDriveStorageQuota 2097152
, More info here: Set the default OneDrive for Business Storage Space
can i also count the files and not only the size?
This should help: Get Number of Items in All Lists and Libraries in SharePoint Online using PowerShell
Can we export Active Users data only?
works great. How would you reset on all users (from csv file) instead of one?
Refer here: OneDrive for Business: How to Increase Storage Quota for a User?
Can you set a Storage Quota with an activeDirectories attribut ? (for exemple “Title” attribut)
Well, its just a matter of framing OneDrive for Business site URL. It uses the below format:
https://DOMAIN-my.sharepoint.com/personal/SAMACCOUNTNAME_DOMAIN_TLD
E.g. If your tenant’s domain is: Crescent.com, and your user name is :Salaudeen, then OneDrive URL is framed as:
https://crescent-my.sharepoint.com/personal/salaudeen_crescent_com
Excellent job. Great blog site. Well done!!! Thank you!
Brilliant Job, Thanks so much – It worked!