$previousRunDate = [Microsoft.SharePoint.Utilities.SPUtility]::CreateISO8601DateTimeFromSystemDateTime([DateTime]::Now.AddDays(-100)) $camlModifiedDateQuery = '<where><Gt><FieldRef Name="Modified" /><Value Type="DateTime">{0}</Value></Gt></Where>' -f $previousRunDate $query = New-Object Microsoft.SharePoint.SPQuery $query.Query = $camlQuery $listItems = $list.GetItems($query) $previousRunDate = [Microsoft.SharePoint.Utilities.SPUtility]::CreateISO8601DateTimeFromSystemDateTime([DateTime]::Now.AddDays(-100)) $camlModifiedDateQuery = '
Sunday, August 4, 2013
PowerShell to Find ListItems Modified Since a Date
Assuming that the list to be queried is already referenced in the $list object in script, here is a simple snippet to retrieve all list items that have been modified within the last one hundred days:
$previousRunDate = [Microsoft.SharePoint.Utilities.SPUtility]::CreateISO8601DateTimeFromSystemDateTime([DateTime]::Now.AddDays(-100)) $camlModifiedDateQuery = '<where><Gt><FieldRef Name="Modified" /><Value Type="DateTime">{0}</Value></Gt></Where>' -f $previousRunDate $query = New-Object Microsoft.SharePoint.SPQuery $query.Query = $camlQuery $listItems = $list.GetItems($query) $previousRunDate = [Microsoft.SharePoint.Utilities.SPUtility]::CreateISO8601DateTimeFromSystemDateTime([DateTime]::Now.AddDays(-100)) $camlModifiedDateQuery = '{0} ' -f $previousRunDate
$query = New-Object Microsoft.SharePoint.SPQuery
$query.Query = $camlQuery
$listItems = $list.GetItems($query)
$previousRunDate = [Microsoft.SharePoint.Utilities.SPUtility]::CreateISO8601DateTimeFromSystemDateTime([DateTime]::Now.AddDays(-100)) $camlModifiedDateQuery = '<where><Gt><FieldRef Name="Modified" /><Value Type="DateTime">{0}</Value></Gt></Where>' -f $previousRunDate $query = New-Object Microsoft.SharePoint.SPQuery $query.Query = $camlQuery $listItems = $list.GetItems($query) $previousRunDate = [Microsoft.SharePoint.Utilities.SPUtility]::CreateISO8601DateTimeFromSystemDateTime([DateTime]::Now.AddDays(-100)) $camlModifiedDateQuery = '
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment