How to find specific data in the Recycle Bin in SharePoint Online.

31.01.20 09:56 PM Comment(s) By Jordan

While technology is great and can do wonderful things, it is only as competent as the person who is using the computer. Humans are not infallible and can make errors. Often times, they are stupid and unintentional.

We recently needed to restore files that were mistakenly deleted by a user. This is not a major issue. However, the recycle bin in question contained over 4 000 items. As we are well aware, trying to find something in the recycle bin can be tedious, especially when you have lots of items. To top it off, there are currently no search functions available for recycle bins.

Running the script.

We needed to view the items and write a script to do so. Below is the script which is to be run from the SharePoint Online Management Shell. The PnP module must also be installed as per the first line in the script.

Some prerequisites are required:

SharePoint Online Management Shell

• Once downloaded, run it as Administrator.

• Install the PnP Module by using the script Install-Module SharePointPnPPowerShellOnline in the SharePoint Online Management Shell;

• Enter in your Site URL using $SiteURL = "https://sitename.sharepoint.com/"

• Hit Enter, and capture your credentials

• Run Get-PnPRecycleBinItem to view the Recycle Bin which will show some files

• Then run Get-PnPRecycleBinItem | Export-Csv C:\recyclebinrestore.csv to export the information to an Excel document.

• In Excel, the document will look like the below:

• Data will be exported into a CSV file. Once there, select the first column can perform the ‘Text to Columns’ option and separate by Comma.

• Select Delimited

• Select Comma, then Finish.

• Your Document will then be neatly formatted.

The full code is displayed below:

https://pastebin.com/embed_iframe/YS22chM7

Jordan

Share -