OneDrive File Issues

How to Export a OneDrive File Inventory to CSV or Excel

Emma BrownEmma Brown Nov 2, 2026 869 views

Question details

The user needs to generate a comprehensive inventory report of all files stored in a OneDrive for Business account, including metadata such as file paths, modification dates, and the names of the individuals who last modified the documents, and export this data to a CSV or Excel format.

How to Export a OneDrive File Inventory to CSV or Excel
Product
OneDrive for Business
Device & OS
not provided
Scenario
Generating an audit or administrative inventory report to track file details and modifications across a OneDrive or SharePoint environment.
Observed behavior
Standard OneDrive interfaces do not offer a direct one-click export for comprehensive metadata, requiring users to leverage SharePoint administration tools, PowerShell scripts, or audit logs to compile the required file inventory into a spreadsheet.
Before you start

Ensure you have SharePoint Administrator or Global Administrator privileges in your Microsoft 365 tenant, as running PowerShell commands against OneDrive for Business sites requires elevated permissions.

Solution 1Recommended

Use SharePoint PnP PowerShell Module

PnP PowerShell is the recommended method for enumerating files within a user's OneDrive for Business site and extracting properties like name, path, and modified date directly to a CSV file.

Because OneDrive for Business is built on SharePoint Online architecture, each OneDrive is essentially a personal SharePoint site collection. Using the PnP PowerShell module allows you to loop through the site's document library and selectively export the metadata you need.

1
Install PnP PowerShell

Open PowerShell as an Administrator. Run the command 'Install-Module -Name PnP.PowerShell' and press Enter. Accept any prompts to install from the untrusted repository.

2
Connect to the OneDrive Site

Use the command 'Connect-PnPOnline -Url <UserOneDriveURL> -Interactive' to authenticate against the specific OneDrive for Business site collection.

3
Retrieve List Items

Fetch the documents by running 'Get-PnPListItem -List "Documents" -PageSize 1000 -Fields "FileLeafRef","FileRef","Modified","Editor"' to capture the necessary metadata fields.

4
Export to CSV

Pipe the results to a CSV file using the command 'Export-Csv -Path "C:\OneDriveInventory.csv" -NoTypeInformation'. You can then open this file in your spreadsheet software.

Use SharePoint PnP PowerShell Module
Script Customization: You may need to format the PowerShell output to properly extract the user's name from the 'Editor' object field before exporting to CSV.
Free Microsoft Office alternative

Analyze Your Exported OneDrive CSV Files with WPS Spreadsheet

After successfully exporting your OneDrive for Business inventory using PowerShell or Purview, you will need a reliable spreadsheet tool to analyze the CSV data. WPS Office serves as a highly compatible, fast, and free alternative to Microsoft Office, making it effortless to organize your audit logs.

  1. 1. Download and Install WPS Office: Download WPS Office for free from the official website and complete the installation on your device.
  2. 2. Open Your Exported CSV: Launch WPS Spreadsheet, go to Menu > Open, and select your newly exported 'OneDriveInventory.csv' file.
  3. 3. Analyze the Inventory: Use the Data > AutoFilter tool to easily sort through file names, paths, dates, and editors within your OneDrive inventory.
Fully compatible with Microsoft Excel (.xlsx, .xls) and CSV file formatsFree and lightweight alternative for processing large data exports quicklyFamiliar user interface ensuring zero learning curve and seamless migrationPowerful built-in tools for sorting, filtering, and creating pivot tables from audit data
microsoft office alternative - wps office

Frequently Asked Questions

Why are some metadata fields missing when I open my exported CSV?

When exporting via PowerShell without explicitly specifying fields, only default properties are returned. Ensure your Get-PnPListItem command includes the '-Fields' parameter with specific names like 'Editor' or 'Modified' to capture complete details.

Can I get an inventory of OneDrive files without using PowerShell?

Yes, but with limitations. You can sync your OneDrive for Business library to your local PC using the OneDrive client, open Command Prompt, navigate to the folder, and type 'dir /s /o:n > inventory.csv'. However, this only captures local file metadata and misses SharePoint-specific data like 'Last Modified By'.

Is Microsoft Graph API an alternative for generating a file inventory?

Yes, developers can use the Microsoft Graph API by querying '/drives/{drive-id}/root/children' to fetch file and folder metadata. However, writing a script to iterate through all folders and parse the JSON output to CSV requires programming expertise.

How do I fix CSV formatting issues where all data appears in one column?

This happens when your spreadsheet software does not recognize the delimiter used in the export. Open the file in WPS Spreadsheet, select the column containing the data, navigate to the 'Data' tab, and use the 'Text to Columns' feature, selecting 'Comma' as your delimiter.