Instantly share code, notes, and snippets.

Embed
What would you like to do?
Sitecore Powershell script to restore items from recycle bin archived after a certain date (e.g. recently deleted)
[datetime]$archivedDate = [datetime]::Today.AddDays(-1)
Write-Host "Restoring items recycled after $($archivedDate.ToShortDateString())"
foreach($archive in Get-Archive -Name "recyclebin") {
Write-Host " - Found $($archive.GetEntryCount()) entries"
$entries = $archive.GetEntries(0, $archive.GetEntryCount())
foreach($entry in $entries) {
if($entry.ArchiveLocalDate -ge $archivedDate) {
Write-Host "Restoring item: $($entry.OriginalLocation) {$($entry.ArchivalId)}on date $($entry.ArchiveLocalDate)"
$archive.RestoreItem($entry.ArchivalId)
} else {
Write-Host "Skipping $($entry.OriginalLocation) on date $($entry.ArchiveLocalDate)"
}
}
}
@michaellwest

This comment has been minimized.

michaellwest commented Aug 2, 2018

This script just saved my bacon. Thanks man!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment