To count your company's OneDrive files, export the OneDrive Usage report from the Microsoft 365 admin center and add the Files column for the accounts you intend to include. For a repeatable PowerShell method, download the same reporting data through Microsoft Graph and sum its File Count and Storage Used (Byte) columns.
This guide covers work OneDrive accounts in Microsoft 365. It helps you answer an AI data company's initial volume questions. The output is a report of counts and storage, rather than a download of the files themselves. For the other tools in your business, use our business data inventory guide.
Choose your method
| Method | Best use | What you get |
|---|---|---|
| Microsoft 365 portal | A visible report you can inspect in Excel | Reported files and used storage per account |
| PowerShell and Graph | A repeatable calculation across accounts | The report CSV, selected rows and a summary |
Start by deciding whether the inventory includes current staff only, former staff whose drives remain available, and accounts marked deleted. Write down the scope before adding numbers.
Before you begin
You need an account allowed to read Microsoft 365 usage reports. For PowerShell, you also need the Graph reporting permission Reports.Read.All, any required administrator consent and an appropriate reporting role. A personal Microsoft account does not provide this company report. Graph reporting permissions (opens in a new tab)
If you lack access, send your administrator this request:
Please export our OneDrive Usage account report, including file count, used storage, deletion status and report refresh date. Please state which work accounts are included. We need aggregate numbers for a data-volume questionnaire.
Method 1 Find the count in the Microsoft 365 portal
- Sign in to the Microsoft 365 admin center (opens in a new tab).
- Open Reports → Usage. Expand Show all if Reports is hidden.
- Select OneDrive, then the Usage tab.
- Display the account table. Use Choose columns to include owner, deletion status, Files, Active files and Storage used.
- Select Export and open the CSV in Excel.
- Keep one row per intended OneDrive account. Retain excluded rows in the original export so the scope remains traceable.
- Add Files and Storage used, recording the units shown in the export. Save the report refresh date as well as the day you downloaded it.
Microsoft documents this report under OneDrive Usage. Its Files metric counts stored files; Active files concerns interaction during the reporting period. The report includes users with a valid OneDrive license. User details can also be concealed by the tenant's reporting privacy settings. Microsoft's OneDrive report guide (opens in a new tab)
Use Files for a stored-file inventory. Choosing a seven-day report does not mean you should report only files someone touched in those seven days. Check the column definition rather than guessing from the date selector.
If names are concealed, you can still produce an aggregate for all included rows. If you must exclude a particular employee's drive, ask the reporting administrator to identify the correct row; do not guess.
Method 2 Download and count with PowerShell
Use a supported PowerShell 7 installation on Windows or Mac. Run these steps in the same PowerShell session. Installation adds the Microsoft modules to your local user profile; the connection signs you into the tenant you specify.
Install-Module Microsoft.Graph.Authentication -Scope CurrentUser
Install-Module Microsoft.Graph.Reports -Scope CurrentUser
Import-Module Microsoft.Graph.Authentication
Import-Module Microsoft.Graph.Reports
Connect-MgGraph -TenantId 'your-tenant-id-or-domain' -Scopes 'Reports.Read.All'
Get-MgContext | Select-Object Account, TenantIdConfirm that the displayed account and tenant are the ones you mean to inventory. Then download the report to a new local folder:
$ErrorActionPreference = 'Stop'
$inventoryDir = Join-Path (Get-Location) ('onedrive-inventory-' + (Get-Date -Format 'yyyyMMdd-HHmmss'))
New-Item -ItemType Directory -Path $inventoryDir -ErrorAction Stop | Out-Null
$reportPath = Join-Path $inventoryDir 'onedrive-raw.csv'
Get-MgReportOneDriveUsageAccountDetail -Period D7 -OutFile $reportPath -ErrorAction Stop
$rows = @(Import-Csv -LiteralPath $reportPath)
if ($rows.Count -eq 0) { throw 'The report has no account rows. Check scope and access.' }
$required = @('Report Refresh Date', 'Is Deleted', 'File Count', 'Storage Used (Byte)')
foreach ($column in $required) {
if ($column -notin $rows[0].PSObject.Properties.Name) {
throw "Missing report column: $column"
}
}
$rows | Select-Object 'Owner Principal Name', 'Is Deleted', 'File Count', 'Storage Used (Byte)' |
Format-Table -AutoSizeThe download command is part of the official Microsoft.Graph.Reports module (opens in a new tab). It writes a CSV locally and does not retrieve document contents.
The calculation below includes report rows marked not deleted. It stops if deletion status is unexpected, numeric fields are blank or rows appear to repeat for an account. If your agreed scope is narrower, filter the selected accounts before calculating.
foreach ($row in $rows) {
if ($row.'Is Deleted' -notin @('True', 'False')) {
throw 'Unexpected deletion status. Inspect the raw report.'
}
}
$included = @($rows | Where-Object { $_.'Is Deleted' -eq 'False' })
if ($included.Count -eq 0) { throw 'No non-deleted account rows were selected.' }
$duplicates = @($included | Group-Object 'Owner Principal Name' | Where-Object { $_.Count -gt 1 })
if ($duplicates.Count -gt 0) { throw 'Repeated account owners found. Review scope before summing.' }
$files = [long]0
$bytes = [long]0
foreach ($row in $included) {
$fileValue = [long]0
$byteValue = [long]0
if (-not [long]::TryParse($row.'File Count', [ref]$fileValue) -or $fileValue -lt 0) {
throw 'Invalid file count. Inspect the raw report.'
}
if (-not [long]::TryParse($row.'Storage Used (Byte)', [ref]$byteValue) -or $byteValue -lt 0) {
throw 'Invalid storage value. Inspect the raw report.'
}
$files += $fileValue
$bytes += $byteValue
}
$included | Export-Csv (Join-Path $inventoryDir 'onedrive-included.csv') -NoTypeInformation
[pscustomobject]@{
Accounts = $included.Count
Files = $files
StorageGB = [math]::Round($bytes / 1e9, 2)
ReportRefreshDates = (($included.'Report Refresh Date' | Sort-Object -Unique) -join '; ')
CollectedAt = (Get-Date).ToString('o')
} | Tee-Object -Variable inventorySummary | Format-List
$inventorySummary | Export-Csv (Join-Path $inventoryDir 'onedrive-summary.csv') -NoTypeInformation
Disconnect-MgGraphStorageGB uses decimal gigabytes: one billion bytes. PowerShell's 1GB constant uses a different divisor, so using it would produce GiB. Preserve the unit with the result when comparing exports.
An empty or repeated owner identifier may trigger the duplicate check when reporting identities are concealed. Inspect the report with your administrator rather than removing the check and assuming the rows are unique.
Find dates and file types separately
The usage report is a good first volume measurement. It does not give you a list of document extensions or the creation date of every file. A drive's last-activity date is not its oldest document date.
If the buyer needs “documents from 2020 onward,” ask an administrator for a scoped metadata inventory, then agree whether “from” means created, modified or the business date inside the record. A migrated PDF can have a recent upload date even when its contents concern an older year.
Likewise, a large average file size does not establish that the drive contains video. Find extensions or inspect an approved sample before claiming a file-type breakdown.
An example from a business inventory
A November 30, 2026 working inventory recorded 1,454 OneDrive files using 82.4 GB across six work accounts, from a report refreshed November 28. That is a useful screening answer when those are the accounts under consideration.
It does not establish that every file is suitable for an AI dataset, that former employees' data was covered, or that all six accounts have the same history. Those questions need their own scope checks.
Keep company SharePoint sites separate using our SharePoint counting guide. If someone copied a file between services, separate service totals still contain two stored copies.
Paste this into the AI data questionnaire
OneDrive: [file count] reported files using [storage and unit] across [account count] work accounts. Report refreshed [date]; collected [date]. Included accounts: [scope]. Deleted accounts: [included/excluded]. File types: [verified breakdown/unknown]. Record dates: [verified range/not yet verified].
If a number differs from a later report, compare refresh dates, included accounts and units before treating it as an error. The inventory is a snapshot of a changing service.
Return to the full inventory checklist, or check your business's fit for data licensing once your counts are ready.