Friday, December 31, 2010

Get files / search files from Recycle Bin - SharePoint 2010





Couple of days back, I got a query. A organization has lots of document libraries & lists. And by mistake a user deleted a file from the document library. The administrator of the site collection is sure that the document is in the recycle bin, but cant find it. Recycle bin has thousands of items in it. The administrator knows the name of the file and he wants to restore it back to the original location.

Microsoft doesn't provide search capabilities inside Recycle Bin. How will you find the specified file? How will you restore it back to the original place? Here is an answer... using PowerShell.

Follow these steps...

Step1. Run the below script to find out about the file in site collection recycle bin.

(Get-SPSite "http://SERVERNAME:PORT/").RecycleBin | ?{$_.Title -match "DeletedFile"}

If a matching file is found, Powershell will display information about the file. You will also be able to find who deleted it.


Step 2. Now take the ID of the item and restore back to the original location.

(Get-SPSite "http://SERVERNAME:PORT").RecycleBin.Restore("e7652991-b3b7-4df2-a3c8-39b76a8e98d3")

Dont forget to run PowerShell as administrator.

-Vighnesh Bendre

1 comment:

Andre Radtke said...

Works like a charme!