Bert Johnson » Blog »

SharePoint PowerShell to Find All Items Modified Since a Certain Date

When doing test migrations or otherwise coordinating multiple environments, it’s sometimes useful to create a list of files modified since a cutoff date.

PowerShell makes it easy:

Add-PSSnapin Microsoft.SharePoint.PowerShell

$dateCutoff = "2015-01-01"
$spQuery = New-Object Microsoft.SharePoint.SPQuery 
$spQuery.Query = "<Where> 
 <Gt> 
 <FieldRef Name='Modified' /> 
 <Value IncludeTimeValue='TRUE' Type='DateTime'>" + $dateCutoff + "</Value>
 </Gt> 
 </Where>"
$spQuery.ViewFields = "<FieldRef Name='EncodedAbsUrl' /><FieldRef Name='Modified' />" 
$spQuery.ViewFieldsOnly = $true

Get-SPWebApplication | Get-SPSite | Get-SPWeb | ForEach-Object { ForEach ($list in $_.Lists) { $listItems = $list.GetItems($spQuery); $listItems | ForEach-Object { $_['EncodedAbsUrl'] + " (" + $_['Modified'] + ")" } } }