How to Export OneDrive Usage Report in Microsoft 365

How to Export OneDrive Usage Report in Microsoft 365?

OneDrive is a key component of Microsoft 365, offering cloud storage for businesses and personal use. If you manage a Microsoft 365 account, you might want to track OneDrive usage to understand how your users are storing and sharing data. The good news is that Microsoft 365 makes it easy to export OneDrive usage report. In this simple guide, we will show you how to do it in just a few steps.

Why Export Microsoft 365 OneDrive Report?

Exporting a OneDrive usage report gives you insight on how your organization is using cloud storage. You can see:

  • How much storage is being used by each user.
  • Who has the most active files.
  • Overall trends in file uploads and downloads.

This data is helpful for IT administrators, especially when managing storage limits or optimizing the user experience.

Export OneDrive Usage Report in Microsoft 365

We can export OneDrive usage reports through Admin Center and Microsoft PowerShell through script.

OneDrive Usage Report Export from Office 365 Admin Center

By default, when we export report, it shows GUID in the report instead of user principal name (UPN). To display the UPN in the report we need to make some changes to the report under ORG settings.

  • Login to your Microsoft 365 account with admin credentials and go to the admin center.
  • Click on the settings, then Org settings in the left side panel of the admin center.

org settings

  • In the right side, click on the reports and uncheck the option “display concealed user, group and site names in all reports” and save.

uncheck and save

  • After saving the changes, click on the Usage under Reports in the left side panel.

click reports then usage

  • Now a new window will open, click on OneDrive and scroll down and click on the Export A new window will open you will be notified of the downloading of the report.

choose onedrive and export OneDrive usage report

Microsoft 365 OneDrive Report through PowerShell

Those who are familiar with the PowerShell and find it easy to use can Export OneDrive Usage report through it.

  • Install Microsoft Graph Module in PowerShell by running the below scripts as an Administrator. It will take some time to install the modules.
Install-Module Microsoft.Graph -Force

Install-Module Microsoft.Graph.Beta -AllowClobber -Force

install graph module

  • Now copy the below PowerShell script and paste it in your notepad. Make changes in the 5th and 6th line of the script by putting the path where you want to export your files.
# Connecting to Microsoft 365 Graph

Connect-MgGraph -NoWelcome -Scopes "User.Read.All", "Reports.Read.All", "ReportSettings.ReadWrite.All"


# Provide Path for the File to Export

$OutputCSVFile = "C:\Users\Manoj\Desktop\OneDriveUsageReport.csv"

$ExportTempFile = "C:\Users\Manoj\Desktop\TemporaryFile.csv"


# If available remove temp file

if (Test-Path $ExportTempFile) {

Remove-Item $ExportTempFile

}


Write-Host "Getting Details of the User Account..." -ForegroundColor Yellow


# Required User Properties

$Prop = 'Id', 'displayName', 'userPrincipalName' 


# Parameters

$UserParameters = @{

All = $true

Filter = "assignedLicenses/`$count ne 0 and userType eq 'Member'"

ConsistencyLevel = 'Eventual'

CountVariable = 'UserCount'

Sort = 'displayName'

}


$Users = Get-MgUser @UserParameters -Property $Prop | Select-Object -Property $Prop


$UserHashag = @{}

foreach ($User in $Users) {

$UserHashag[$User.userPrincipalName] = $User

}


# Retrieve Last 90 Days OneDrive Report

Write-Host "OneDrive Site Usage..." -ForegroundColor Cyan

Get-MgReportOneDriveUsageAccountDetail -Period D90 -Outfile $ExportTempFile


$OneDriveBusinessSites = Import-CSV $ExportTempFile | Sort-Object 'User display name'


if (-not $OneDriveBusinessSites) {

Write-Host "Site not Found" -ForegroundColor Yellow

return

}


$OneDriveBusinessSiteUsed = [Math]::Round(($OneDriveBusinessSites.'Storage Used (Byte)' | Measure-Object -Sum).Sum / 1GB, 2)


$Report = [System.Collections.Generic.List[PSCustomObject]]::new()


foreach ($Site in $OneDriveBusinessSites) {

$UserData = $UserHashag[$Site.'Owner Principal name']

$ReportLine = [PSCustomObject]@{

Owner = $Site.'Owner display name'

UserPrincipalName = $Site.'Owner Principal name'

SiteId = $Site.'Site Id'

IsDeleted = $Site.'Is Deleted'

LastActivityDate = $Site.'Last Activity Date'

FileCount = $Site.'File Count'

ActiveFileCount = $Site.'Active File Count'

QuotaGB = [Math]::Round($Site.'Storage Allocated (Byte)' / 1GB, 2)

UsedGB = [Math]::Round($Site.'Storage Used (Byte)' / 1GB, 2)

PercentUsed = [Math]::Round($Site.'Storage Used (Byte)' / $Site.'Storage Allocated (Byte)' * 100, 2)

}

$Report.Add($ReportLine)

}


$Report | Sort-Object UsedGB -Descending | Export-CSV -NoTypeInformation -Encoding utf8 $OutputCSVFile

$Report | Sort-Object UsedGB -Descending | Out-GridView -Title OneDriveUsageReport


Write-Host ("OneDrive Consumption is {0} GB. Saving Report to {1}" -f $OneDriveBusinessSiteUsed, $OutputCSVFile) -ForegroundColor Cyan


if (Test-Path $ExportTempFile) {

Remove-Item $ExportTempFile

Write-Host "Temporary export file removed." -ForegroundColor Cyan

}
  • After making changes, copy the script and run it in Windows PowerShell. The final output after completion on the script will be as below.

powershell output

  • Also, a window will open showing the data of the report.

powershell report

  • You can also go to the location where you chose to export your OneDrive Usage Report file. You can open it in Excel or any spreadsheet tool to analyze the data. Look for trends like heavy storage users or inactive accounts, which can help you manage your resources more effectively.

Final OneDrive Usage Report

 

Conclusion:

Exporting a OneDrive usage report in Microsoft 365 is quick and easy. With just a few clicks, you can export valuable insights about how your users interact with OneDrive. Both the methods mentioned in this article are easy and can be used to export OneDrive usage report. Whether you need reports for Checking storage space or for specific reasons, this guide has got you covered.

Comments

No comments yet. Why don’t you start the discussion?

Leave a Reply

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