Question

Running SharePoint Online under Office 365.

Is it possible to restore all items from a Document library recycle bin? e.g. a PowerShell command? I can only see how to restore selected items.

Was it helpful?

Solution

You can read this article from

http://sharepointandaspnet.blogspot.com/2015/09/sharepoint-online-how-to-restore.html

The script takes the following params: Site collection administrator User name who deleted files Site collection url Timestamp of items deleted date (ex., strart 2015-09-03 00:00:00 and end date 2015-09-03 23:59:59)

The script does the following actions:

Takes all site collection Recycle bin items and assign it into an array variable It sorts an array in descending using merge method (https://gallery.technet.microsoft.com/scriptcenter/Merge-Sort-for-PowerShell-e5fdf3ab) (the first record in the last deleted) Limit deleted items count to the start date you enter in the script (ex. If recycle bin contains 8000 items from 2015-06-01 till 2015-09-09 and you want to restore items deleted for one particular day 2015-09-03, the items count will be limited to the start date) Checks if deleted item is equal to timestamp Checks the user you entered in input Creates CSV report with sorted and deleted by the user items Restores deleted items one by one from $csvReport filtered and sorted array with following methods

                                 $_.DeletedItem.Restore()
                                 $ctx.ExecuteQuery()

Maybe you will find an answer.

OTHER TIPS

You can loop through items in recycle bin to restore all :

$recyclebinitems = (Get-SPWeb "_http://< sitename:portno >" ).RecycleBin 
foreach($recyclebinitem in $recyclebinitems)
{

    (Get-SPWeb "_http://<site>").RecycleBin.Restore($recyclebinitem.ID)
 }

Ref: Restore all items from recycle bin

Edit: I missed that you are looking for MSOnline. This code is for on-prem. But may be helpful for getting insight as it works perfectly for on-prem.

We ran into a very frustrating issue when one of my client's employees hard drives ran out of space, and that employee deleted all the files in his documents folder, which happened to be synchronized with Sharepoint.

55k files deleted. We could see them in the recycle bin, but could only recover ten or so files at a time. It would take years to recover at that rate!

After much fiddling - we tried using the above powershell script, tried different approaches to the web portal, talked to support - nothing yielded results until...

I found a link at bottom left of the recycle bin window that said "Open Classic Site". I clicked it, and lo and behold, through this classic site I was able to restore 200 files at a time!

It took a couple of hours to recover everything but that is less time than I lost screwing around with scripts and other methods.

Here is the difference between the sharepoint links:

Could only restore up to ten items at a time through this link: https://(customerurl).sharepoint.com/sites/(sitename)/_layouts/15/RecycleBin.aspx?view=5

Could restore 200 at a time through this link: https://(customerurl).sharepoint.com/sites/(sitename)/_layouts/15/AdminRecycleBin.aspx?ql=1

Hope this helps someone!

Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top