PowerShell script to empty SharePoint Recycle Bins

InfoPath alternatives for form designing SharePoint

In this post we will discuss how to empty SharePoint recycle bin using PowerShell.

Below is the PowerShell command to delete Recycle Bin using PowerShell.

$WebApp=get-spwebapplication “Enter URL”
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 (2nd Stage Recycle bin) or Admin Recycle bin
$SPSite.RecycleBin.DeleteAll();
write-host “Administrator Recycle bin Items Deleted for:” $SPSite.RootWeb.title “`n”
}

Similar SharePoint 2013 Tutorials


Leave a Reply