How to Export Document Metadata from SharePoint
SharePoint has a built-in Export to Excel option for document libraries. For more control, PowerShell and the Microsoft 365 CLI give you full flexibility.
SharePoint is the most export-friendly platform in this guide series. Any user with read access can click Export to Excel on a document library and get a spreadsheet of all file metadata in that library. For automated, repeatable, or cross-site exports, PnP PowerShell is the standard tool.
Export to Excel (Built-in)
This is the fastest path. One click from any document library, and you have a live Excel spreadsheet connected to your SharePoint data. You can then save it as a regular Excel file or CSV.
.iqy file..iqy file. Excel will launch and prompt you to enable the data connection. Click Enable. Your file metadata will load as a table..iqy file as potentially unsafe since it creates a data connection. This is expected behavior — the file connects to your SharePoint site to pull data. If your organization blocks .iqy downloads, use Method 2 or Method 3 instead.PnP PowerShell
PnP PowerShell (Patterns and Practices) is the most widely used community tool for SharePoint automation. It gives you full control over which fields to export, handles large libraries with pagination, and outputs directly to CSV. IT admins can run this across entire site collections in a single script.
Install-Module PnP.PowerShell -Scope CurrentUserConnect-PnPOnline -Url "https://contoso.sharepoint.com/sites/yoursite" -Interactive-List name and -Fields to match your library and the metadata columns you need.# Connect to SharePoint
Connect-PnPOnline -Url "https://contoso.sharepoint.com/sites/yoursite" -Interactive
# Export document library metadata to CSV
$items = Get-PnPListItem -List "Documents" -PageSize 1000 -Fields \
"FileLeafRef","Title","Created","Modified","Editor","Author", \
"File_x0020_Size","ContentType","CustomColumn1","TaxonomyField1"
$results = $items | ForEach-Object {
[PSCustomObject]@{
FileName = $_["FileLeafRef"]
Title = $_["Title"]
Created = $_["Created"]
Modified = $_["Modified"]
ModifiedBy = $_["Editor"].LookupValue
CreatedBy = $_["Author"].LookupValue
Size = $_["File_x0020_Size"]
ContentType = $_["ContentType"].Name
CustomField = $_["CustomColumn1"]
ManagedMeta = $_["TaxonomyField1"].Label
FilePath = $_["FileRef"]
}
}
$results | Export-Csv -Path "sharepoint_metadata.csv" -NoTypeInformation
Write-Host "Exported $($results.Count) items to sharepoint_metadata.csv"Get-PnPList -BaseTemplate DocumentLibrary to get all libraries, then loop through each one with the export script above. This is particularly useful for site-wide metadata audits.CLI for Microsoft 365
The CLI for Microsoft 365 (formerly Office 365 CLI) is a cross-platform Node.js tool that works on macOS, Linux, and Windows. It provides a one-liner for exporting SharePoint list items directly to CSV.
npm install -g @pnp/cli-microsoft365m365 login and follow the browser authentication prompt.--output csv flag produces CSV directly.# Log in to Microsoft 365
m365 login
# Export document library metadata as CSV
m365 spo listitem list \
--webUrl "https://contoso.sharepoint.com/sites/yoursite" \
--title "Documents" \
--fields "FileLeafRef,Title,Created,Modified,Editor,Author,File_x0020_Size" \
--output csv > sharepoint_metadata.csvWhat metadata fields can you export?
| Field | Export to Excel | PnP PowerShell | M365 CLI |
|---|---|---|---|
| File name | ✓ | ✓ | ✓ |
| File path | ✓ | ✓ | ✓ |
| File size | ✓ | ✓ | ✓ |
| Created date | ✓ | ✓ | ✓ |
| Modified date | ✓ | ✓ | ✓ |
| Created by | ✓ | ✓ | ✓ |
| Modified by | ✓ | ✓ | ✓ |
| Content type | ✓ | ✓ | ✓ |
| Custom columns (text, choice, number) | ✓ | ✓ | ✓ |
| Managed metadata (term label) | ✓ | Label only | Label only |
| Managed metadata (full term path) | ✕ | Extra API call | ✕ |
| Person/group columns | ✓ | ✓ | ✓ |
| Lookup columns | ✓ | ✓ | ✓ |
| Version number | Current only | ✓ | ✓ |
| Check-in/out status | ✓ | ✓ | ✓ |
| Item-level permissions | ✕ | Separate call | ✕ |
| Version history | ✕ | Per-item call | ✕ |
- 5,000-item view threshold: SharePoint limits list views to 5,000 items. Export to Excel respects this limit. PnP PowerShell handles it with the
-PageSizeparameter, which paginates automatically. - Managed metadata term paths: All three methods return the term label (e.g., "United States") but not the full hierarchy path (e.g., "Geography > North America > United States"). Getting full paths requires additional calls to the Term Store API.
- SharePoint On-Premises: Export to Excel and PnP PowerShell work on on-prem. CLI for Microsoft 365 and Microsoft Graph API are SharePoint Online only.
You have your metadata export.
Now score it.
Upload your CSV or Excel file to MQS and get a structural metadata health score out of 100 with dimension breakdowns and actionable diagnostics.