Sitecore Powershell script to restore items from recycle bin archived after a certain date (e.g. recently deleted)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[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)" | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This script just saved my bacon. Thanks man!