Office 365: Get OneDrive for Business Usage Report using PowerShell

Requirement: Get OneDrive for business usage report using PowerShell

How to Check the OneDrive for Business Usage for a User in Office 365?

OneDrive for Business is Microsoft’s cloud-based storage solution that lets you store and work on files that are personal to you. It’s similar to any other document library in SharePoint with full control granted to you so that you can add, update, and delete files or folders in your OneDrive. To get the storage usage on OneDrive for business for a specific user,

  • Login to Office 365 Admin Centre, Search, and find the user.
  • From the user settings page, expand the OneDrive for business settings menu and under Quota You’ll see the Storage used value!
    onedrive for business usage powershell

PowerShell to Check OneDrive for Business Usage

Here is the PowerShell to check OneDrive for business usage.

#Variables
$AdminSiteURL="https://crescent-admin.sharepoint.com"
$OneDriveURL = "https://crescent-my.sharepoint.com/personal/salaudeen_crescent_com"
 
#Connect to SharePoint Online Admin Center
Connect-SPOService -Url $AdminSiteURL # -credential (Get-Credential)

#Get All Properties of the OneDrive Site
Get-SPOSite $OneDriveURL | Select -Property *

To get OneDrive for business site size using PowerShell, you can use:

Get-SPOSite $OneDriveURL | Select @{Name="Storage Used";Expression={$_.StorageUsageCurrent}}

How about getting OneDrive for Business storage space for all sites? Well, using PowerShell we can create a
quick report to check how much storage does OneDrive for business sites have.

#Variable for SharePoint Online Admin Center URL
$AdminSiteURL="https://crescent-admin.sharepoint.com"
 
#Connect to SharePoint Online Admin Center
Connect-SPOService -Url $AdminSiteURL -credential (Get-Credential)

#Get All OneDrive Sites
Get-SPOSite -IncludePersonalSite $true -Limit all -Filter "Url -like '-my.sharepoint.com/personal/'"

This PowerShell script pulls all OneDrive for Business sites.

onedrive for business usage report using powershell

Export OneDrive for Business sites storage size report to CSV

Let’s pull Onedrive for business usage using powershell and export the result to CSV file.

#Variable for SharePoint Online Admin Center URL
$AdminSiteURL="https://crescent-admin.sharepoint.com"
$CSVFile = "C:\Temp\OneDrives.csv"
 
#Connect to SharePoint Online Admin Center
Connect-SPOService -Url $AdminSiteURL -credential (Get-Credential)

#Get All OneDrive Sites usage details and export to CSV
Get-SPOSite -IncludePersonalSite $true -Limit all -Filter "Url -like '-my.sharepoint.com/personal/'" | Select URL, Owner, StorageQuota, StorageUsageCurrent, LastContentModifiedDate | Export-Csv -Path $CSVFile -NoTypeInformation

This PowerShell script retrieves URL, Owner, Storage Quota allocated, Storage Used and Last Updated Date property values of all OneDrive for Business sites and generates report as below:

powershell check onedrive for business usage

This generates a report listing all OneDrive for Business sites in the tenant with the storage allocated and used for each site. Here is another post to get OneDrive storage quota using PowerShell: Get OneDrive for Business Size using PowerShell

Salaudeen Rajack

Salaudeen Rajack is a SharePoint Architect with Two decades of SharePoint Experience. He loves sharing his knowledge and experiences with the SharePoint community, through his real-world articles!

2 thoughts on “Office 365: Get OneDrive for Business Usage Report using PowerShell

  • May 5, 2021 at 8:39 AM

    thanks this was useful a the second I needed it

    Reply
  • November 17, 2020 at 8:11 PM

    N.B. If you have MFA enabled, you have to omit the `-credential (Get-Credential)` clause.

    Without it, the command will prompt for your credentials in a web window, allowing you to use MFA.

    Reply

Leave a Reply