Search the recycle bin with Powershell

Useful piece of Powershell to search for a file(s) / item(s) in the site recycle bin and then restore it/them.

Change the regular expression after match to change what files to search for.

$spsite = (Get-SPSite "http://mysite" )
$files = $spsite.RecycleBin | ?{$_.Title -match "myfile\d{2}"}

foreach ($file in $files) {

Write-Host "Found $($file.Title)"
$spsite.RecycleBin.Restore($file.ID)

}

You may also like: