SharePoint Document Issues

How to Export SharePoint Online Library Files to CSV with PowerShell

Natalie TaylorNatalie Taylor Nov 4, 2026 869 views

Question details

The user needs to generate an inventory of all PDF files located across multiple SharePoint Online site collections and document libraries, and export these results into a single CSV file.

Product
SharePoint Online
Device & OS
not provided
Scenario
Creating a comprehensive, tenant-wide file inventory for auditing or management purposes.
Observed behavior
The user requires an automated script-based approach to extract the file list into a CSV format, avoiding the repetitive task of manually exporting each library.
Before you start

Ensure you have SharePoint Online Administrator privileges and that the SharePoint Online Management Shell is installed on your computer before attempting to run tenant-wide scripts.

Solution 1Recommended

Use PowerShell to Automate the CSV Export

Deploy a PowerShell script to automatically iterate through all site collections and document libraries, filter for PDF files, and export the aggregated data to a CSV.

Using PowerShell is the most efficient method for extracting data across multiple site collections, as it eliminates the need to visit each document library manually.

1
Launch the Management Shell

Open the SharePoint Online Management Shell on your computer as an administrator.

2
Connect to SharePoint Online

Use the 'Connect-SPOService' cmdlet and input your SharePoint admin center URL to authenticate your session.

3
Execute the inventory script

Run a custom PowerShell script utilizing 'Get-SPOSite' and 'Get-PnPListItem' (if using PnP PowerShell) to loop through all document libraries and filter items where the file extension equals '.pdf'.

4
Export the results

Append the 'Export-Csv' cmdlet at the end of your script pipeline to output the collected file properties (like File Name, URL, and Size) to a local CSV file on your hard drive.

Use PowerShell to Automate the CSV Export
Script Development Assistance: If you require specific code snippets or script troubleshooting, post your queries in the Microsoft Q&A SharePoint development forum.
Free Microsoft Office alternative

Analyze Your Exported CSV Inventory with WPS Office

Once your PowerShell script has successfully generated the CSV inventory of your SharePoint files, WPS Office provides a free, lightweight, and highly compatible alternative to Microsoft Excel for reviewing and managing that data.

  1. 1. Install WPS Office: Download and install the free WPS Office suite on your computer.
  2. 2. Open your CSV file: Launch WPS Spreadsheet, click 'Open', and select the CSV file generated by your PowerShell script.
  3. 3. Analyze the data: Use the Data tab to apply filters, adjust column widths, and format your SharePoint file inventory.
Fully compatible with Microsoft Office formats, ensuring your .csv, .xlsx, and .xls files open flawlessly.Lightweight architecture allows for instant opening of massive CSV data files without lagging.Completely free to use with a familiar user interface that requires no learning curve.Includes robust Data tools like auto-filter, sorting, and pivot tables to easily analyze your PDF file inventory.
microsoft office alternative - wps office

Frequently Asked Questions

Can I run the PowerShell export script without admin privileges?

No. Iterating through all site collections across a tenant requires SharePoint Administrator or Global Administrator credentials to ensure you have access to all document libraries.

Why is the 'Export to Excel' button missing in my SharePoint library?

The export option may be hidden if offline client availability is disabled in the library's advanced settings, or if you are using a customized view that restricts command bar features.

Does exporting to CSV via PowerShell impact SharePoint performance?

Running extensive scripts against a large tenant can cause throttling. It is recommended to use pagination, run the script during off-peak hours, or use Microsoft Graph API for large-scale operations to minimize performance impacts.