In this post we are going to see how we can search from
recycle bin. Now out of the box there is no way to search an item from recycle
bin and restore it.
The problem is when we have a lot of items in the recycle
bin we need to page through and then find that item and then restore it.
Well there is a PowerShell that can come to rescue.
Here are simple steps to perform in PowerShell to find and
restore the item.
$spSite= Get-SPSite $site$web = $spSite.OpenWeb()$files = $web.RecycleBin | ?{$_.Title -match “tst”}foreach ($file in $files){Write-Host “Found $($file.Title)”$web.RecycleBin.Restore($file.ID)Write-Host “Restored $($file.Title)”}
The script is pretty self explanatory. Get the site and then
web object. Then take the recycle bin. It is first stage recycle bin. You can
also take the second stage recycle bin from site object as well.
Then just search for item from recycle bin with title
property. The above code returns all the items from recycle bin which has a tst
as a match and then calls restore method to restore it to their respective
locations.
If you know the exact name of an item, you can write that
and that specific item will be restored. See the advantage, you do not need to
search from pages by paging through them if you have huge amount of items
residing in recycle bin.
I hope this helps.
No comments:
Post a Comment