1

I have a SharePoint online library called MyLibrary, it contains approx. 4000 items.

The items got deleted, and I need to restore them using PnP PowerShell, the following are the challenges I am facing, any help on it will be appreciated:

  1. items are deleted on various dates, so cant filter on date
  2. items are deleted by a single shared account, so filtering that user will select those items other than MyLibrary's items also.
  3. Approx. 3000 items need to be restored
  4. tried to restore using UI it is taking quite some time

I think if I can get the internal name for Original Location then filter can be applied, but cant get the internal name for it.

Please find the screenshot for recycle bin column headers:

Recycle bin with see yellow highlighted

Script I think of using is:

Get-PnPRecycleBinItem | Where {$_.Original Location -like "*/mylib"} | Restore-PnpRecycleBinItem -Force
1

You can get the recycle bin items based on Original Location like below:

Get-PnPRecycleBinItem | ? DirName -Like '*/mylib'

Use DirName column for Original Location.


Example:

Get-PnPRecycleBinItem | ? DirName -Like '*/Lists/Test_List’

Output:

enter image description here

3
  • Hi @Ashish, did you try my suggestions? Is it working for you? Let me know if you need any further help with this. Jul 12 at 13:56
  • HI @ganesh sanap , thanks !!, yes it is working :)
    – Ashish
    Jul 13 at 13:08
  • Great, glad it worked for you. Please Upvote(^) and accept as an Answer as it helped you & it will help others with similar question in future to find the correct answer easily. It also removes this question from "Unanswered questions" list. Jul 13 at 13:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.