Archive

Posts Tagged ‘recycle-bin’

Search the recycle bin with Powershell

17 October 2012 Leave a comment

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)

}

Advertisements
Categories: Code Tags: , ,