1

I have an app that can run Node.js and Powershell commands (Electron) and I'm trying to figure out the best (or any) way to restore from recycle bin either:

  • The last deleted items
  • or items deleted in specific time period (e.g. last 5 minutes)
  • or (preferable) specific paths

I found this answer but I don't have enough Powershell experience to apply it for my case.

So far I only figured a way to list recycle bin items:

function RestoreItems () {
  $recycleBin = (New-Object -ComObject Shell.Application).NameSpace(0x0a);
  $recycleBin.Items() | ForEach-Object {
    # unfinished code:
    $originalPath = $_.ExtendedProperty(...)
    Copy-Item $_.Path ($originalPath)
  }
}

RestoreItems -Paths ['C:\test\1', 'C:\test\2']

Which outputs all recycle bin items with all the properties that I need (name and date).

Assuming that I have an array of file names that I need to restore, how do I do that?

AlekseyHoffman
  • 2,438
  • 1
  • 8
  • 31

0 Answers0