List modified files¶
Description¶
List modified files in a SharePoint Online Document Library to a csv file.
Useful if you need to restore backup but see what has been modified since then.
Note: Modern versions of Connect-PnPOnline are exclusively supported on PowerShell 7+
Code¶
Install-Module PnP.PowerShell -Scope CurrentUser
# Variables
$SiteUrl = "https://Tenant.sharepoint.com/sites/SiteName"
$Since = Get-Date "2026-06-21"
$clientId = "GET_FROM_ENTRA"
$tenant = "company.com"
Connect-PnPOnline -Url $SiteUrl -ClientId $clientId -Tenant $tenant -Interactive
Get-PnPList | Where-Object { $_.BaseTemplate -eq 101 -and -not $_.Hidden } | ForEach-Object {
$Library = $_.Title
Get-PnPListItem -List $Library -PageSize 2000 -Fields "FileRef","FileLeafRef","Modified","Editor" |
Where-Object {
$_["FSObjType"] -eq 0 -and
[datetime]$_["Modified"] -ge $Since
} |
Select-Object `
@{n="Library";e={$Library}},
@{n="FileName";e={$_["FileLeafRef"]}},
@{n="Path";e={$_["FileRef"]}},
@{n="Modified";e={$_["Modified"]}},
@{n="ModifiedBy";e={$_.FieldValues.Editor.LookupValue}}
} | Export-Csv ".\SharePointFilesModified.csv" -NoTypeInformation