Microsoft 365: Get OneDrive for Business Usage Report using PowerShell

Requirement: Get OneDrive for business storage usage reports using PowerShell.

How to Check the OneDrive for Business Storage 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 offers easier collaboration, better accessibility, and increased security compared to traditional storage methods. With OneDrive, you can share your files with others and work on Office documents in real-time (Co-authoring). 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.

While OneDrive offers many benefits, it’s essential to keep an eye on your OneDrive storage usage to review where space is being used most efficiently and ensure you don’t run out of space. OneDrive’s usage reports can be obtained in a couple of ways, and this post will show you how to check your OneDrive storage usage reports.

To get the storage usage on OneDrive for business for a specific user, do the following:

  1. Login to Office 365 Admin Center, Search and click on the user display name.
  2. From the user settings page, Click on the OneDrive tab, and you’ll see the storage space used value!
    onedrive for business usage report powershell

Check Your OneDrive Storage Quota Usage

How do I check my OneDrive for Business storage space? Here is how to check OneDrive usage and see how much storage is left as a site owner:

  1. Open your OneDrive site in the web browser (Shortcut: https://YourDomain-my.SharePoint.com)
  2. Click on Settings >> OneDrive Settings >> Click on “More Settings”
  3. Click on the “Storage Consumption” link (URL shortcut: https://YourDomain-my.sharepoint.com/personal/YourID_YourDomain_com/_layouts/15/storman.aspx).

In the Storage section, you’ll see how much space you have used, which folders and files are taking up most of the space in your account and how much space is available. You can also get another user’s OneDrive storage consumption if you have access to their sites.

check onedrive usage in microsoft 365
How much storage do I get with OneDrive for Business? Most of the Microsoft 365 plans offer 1 TB storage space!

How to Get OneDrive Storage Usage in Office 365 Reports?

How to check OneDrive usage for all users? To get the OneDrive usage report for all users through Microsoft 356 admin center, follow these steps:

  1. Login to Microsoft 365 Admin center at https://admin.microsoft.com
  2. Click on Reports >> Usage in the left navigation
  3. Under OneDrive Files, Click on View More
  4. Scroll down a bit to view the report that provides insights such as the current number of files, storage used, etc. You can also export the report data into a CSV format for further analysis.how to check onedrive storage usage

PowerShell to Check OneDrive for Business Usage

Here is the PowerShell to check OneDrive for business usage using the Get-SPOSite cmdlet:

#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 users? Using PowerShell, we can create a quick report to check how much storage 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 a OneDrive for business usage using PowerShell and export the result to a 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 the URL, Owner, Storage Quota allocated, storage Used, and Last Updated Date property values of all OneDrive for Business sites and generates a report as below:

powershell check onedrive for business usage

PnP PowerShell to check OneDrive Storage Usage

We can also check OneDrive usage with the PnP PowerShell module and export the data to a CSV report. This OneDrive report gives you details: UsedGB, Last activity date, total storage allocated, etc.

#Config Variables
$TenantAdminURL = "https://crescent-admin.sharepoint.com"
$ReportOutput = "C:\Temp\OneDriveUsage.csv"

#Connect to Admin Center using PnP Online
Connect-PnPOnline -Url $TenantAdminURL -Interactive

#Get All OneDrive sites
$OneDriveSites = Get-PnPTenantSite -IncludeOneDriveSites -Filter "Url -like '-my.sharepoint.com/personal/'" -Detailed

$UsageData = @()
#Loop through each site collection
ForEach($Site in $OneDriveSites)
{
    Try {
        Write-host "Processing Site:"$Site.URL -f Yellow

        #Collect OneDrive usage data
        $UsageData += [PSCustomObject][ordered]@{
            SiteName         = $Site.Title
            URL              = $Site.URL
            Owner            = $Site.owner
            UsedSpaceMB      = $Site.StorageUsageCurrent
            AllocatedSpaceGB = [Math]::Round($Site.StorageQuota/1024,2)
            LastUsed         = $Site.LastContentModifiedDate
        }
    }
    Catch {
        write-host "Error: $($_.Exception.Message)" -foregroundcolor Red
    }
}
#Export the data to CSV Report
$UsageData | Format-table
$UsageData | Export-Csv -Path $ReportOutput -NoTypeInformation

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

In conclusion, getting a OneDrive for Business usage report using Microsoft 365 Admin center or PowerShell can be useful to monitor and manage the usage of OneDrive within your organization. By using the methods provided in this guide, you can retrieve the usage information such as the number of users, the amount of storage used, and the number of files and folders. This information can help you identify areas of high usage, potential security risks, and potential issues with storage capacity. Additionally, it can also help in identifying the users who are not using OneDrive for Business and taking the necessary actions.

Salaudeen Rajack

Salaudeen Rajack - SharePoint Expert with Two decades of SharePoint Experience. Love to Share my knowledge and experience with the SharePoint community, through real-time articles!

3 thoughts on “Microsoft 365: Get OneDrive for Business Usage Report using PowerShell

  • How can we get user license info on the same report

    Reply
  • thanks this was useful a the second I needed it

    Reply
  • 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

Your email address will not be published. Required fields are marked *