I have this powershell script to delete all items from a list:

$siteURL = "URL"
$site = new-object Microsoft.SharePoint.SPSite ( $siteURL )
$web = $site.OpenWeb()
$oList = $web.Lists["ListName"];
$collListItems = $oList.Items;
$count = $collListItems.Count -1;
for($intIndex = $count; $intIndex -ge 0; $intIndex--)

I was wondering if it is possible to edit this script to only delete items that were created over 90 days ago (or delete items that were created before a certain date)?

1 Answer 1


Here's a question which is similar to yours and already answered:

You can replace the Date beeing compared with this:

$DateToCompare = (Get-date).AddDays(-90)

powershell to delete items from a list where created date < "1/1/2011"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.