We were doing testing and we generated lots of documents and lists and needed to eliminate those documents, so instead of eliminating files one by one we used the following PS code:
$WebApp=get-spwebapplication "https://yourappweb" foreach ($SPSite in $webApp.Sites) { #get the collection of webs foreach($SPWeb in $SPSite.AllWebs) { #Empty the 1st Stage Recycle bin items PERMENANTLY $SPWeb.RecycleBin.DeleteAll(); #Send the 1st Stage Recycle bin items to 2nd Stage $SPWeb.RecycleBin.MoveAllToSecondStage(); write-host "End-User Recycle Bin Items Deleted for:" write-host $SPWeb.title ":" $SPWeb.URL "`n" } #Empty SharePoint site collection recycle bin (Second Stage Recycle bin) or Admin Recycle bin $SPSite.RecycleBin.DeleteAll(); write-host "Administrator Recycle bin Items Deleted for:" $SPSite.RootWeb.title "`n" }
hope it helps!
Sweet! Simple, clear and useful.
LikeLike
Glad that had helped you 🙂
LikeLike
How do you filter by user who deleted and then only move to second stage?
LikeLike
When I was doing this, I was deleting all the objject, so, I didn’t have the necessity to filter by user. If you’re able to do this, I will be interested in knowing the solution
LikeLike