The Recycle Bin search in XM Cloud doesn’t work. Try this instead!

I had someone ask me to restore an item from the recycle bin in XM Cloud today. Generally not a difficult task, assuming it hasn’t been 30 days since the deletion when it should get flushed. But, I’ve come to find that the recycle bin in XM Cloud, whil…


This content originally appeared on DEV Community and was authored by Kenneth McAndrew

I had someone ask me to restore an item from the recycle bin in XM Cloud today. Generally not a difficult task, assuming it hasn't been 30 days since the deletion when it should get flushed. But, I've come to find that the recycle bin in XM Cloud, while it has a search, that search...doesn't work. You get a script error.

Now, in the collection of tools, the recycle bin seems to be a relic of the "old" era - it's in the Desktop of the Content Editor system, and I don't as yet see an equivalent in Explorer or Pages. But it's still a pretty useful tool. Fortunately, there's another way to do this...good old Sitecore PowerShell.

I remembered from something else I was messing with once that there was a way to get into the recycle bin, so a little documentation and AI searching and crafting, and we get the following number. This script will both search for a term in the name or original path, and if you choose will restore the item(s) back to the master database. A quick little workaround for that pesky search problem!

$searchTerm = ""
$restoreItems = $false

$database = Get-Database -Name "master"
$archive = Get-Archive -Database $database -Name "recyclebin"

# Get all items in the recycle bin
$archiveItems = Get-ArchiveItem -Archive $archive |
    Where-Object {
        $_.Name -match $searchTerm -or
        $_.OriginalLocation -match $searchTerm
    }

foreach ($archivedItem in $archiveItems) {
    Write-Host "Found deleted item: $($archivedItem.Name) | ID: $($archivedItem.ArchivalId) | Path: $($archivedItem.OriginalLocation)"

    if ($restoreItems) {
        Restore-ArchiveItem -Archive $archive -ItemId $archivedItem.ArchivalId
        Write-Host "Restored deleted item: $($archivedItem.Name) | ID: $($archivedItem.ArchivalId) | Path: $($archivedItem.OriginalLocation)"
    }
}


This content originally appeared on DEV Community and was authored by Kenneth McAndrew


Print Share Comment Cite Upload Translate Updates
APA

Kenneth McAndrew | Sciencx (2025-09-22T19:59:04+00:00) The Recycle Bin search in XM Cloud doesn’t work. Try this instead!. Retrieved from https://www.scien.cx/2025/09/22/the-recycle-bin-search-in-xm-cloud-doesnt-work-try-this-instead/

MLA
" » The Recycle Bin search in XM Cloud doesn’t work. Try this instead!." Kenneth McAndrew | Sciencx - Monday September 22, 2025, https://www.scien.cx/2025/09/22/the-recycle-bin-search-in-xm-cloud-doesnt-work-try-this-instead/
HARVARD
Kenneth McAndrew | Sciencx Monday September 22, 2025 » The Recycle Bin search in XM Cloud doesn’t work. Try this instead!., viewed ,<https://www.scien.cx/2025/09/22/the-recycle-bin-search-in-xm-cloud-doesnt-work-try-this-instead/>
VANCOUVER
Kenneth McAndrew | Sciencx - » The Recycle Bin search in XM Cloud doesn’t work. Try this instead!. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2025/09/22/the-recycle-bin-search-in-xm-cloud-doesnt-work-try-this-instead/
CHICAGO
" » The Recycle Bin search in XM Cloud doesn’t work. Try this instead!." Kenneth McAndrew | Sciencx - Accessed . https://www.scien.cx/2025/09/22/the-recycle-bin-search-in-xm-cloud-doesnt-work-try-this-instead/
IEEE
" » The Recycle Bin search in XM Cloud doesn’t work. Try this instead!." Kenneth McAndrew | Sciencx [Online]. Available: https://www.scien.cx/2025/09/22/the-recycle-bin-search-in-xm-cloud-doesnt-work-try-this-instead/. [Accessed: ]
rf:citation
» The Recycle Bin search in XM Cloud doesn’t work. Try this instead! | Kenneth McAndrew | Sciencx | https://www.scien.cx/2025/09/22/the-recycle-bin-search-in-xm-cloud-doesnt-work-try-this-instead/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.