Clear SharePoint Site’s Recycle Bin using PowerShell Script

Displaying use of powershell script for deleting all items from SharePoint site's Recycle Bin

In this blog post I’m going to display how to delete all items from recycle bin of any SharePoint Site using PowerShell script.

Steps:

  1. PowerShell script we can get the object of SPSite and SPWeb like this
    $Site = Get-SPSite “SiteUrl”
    $RootWeb = $Site.RootWeb
  2. We can iterate through all the subsites in any site using foreach loop
    foreach($web in $RootWeb.Webs)
  3. Next we need to call the DeleteAll method of Recycle Bin.
    {
          $web.RecycleBin.DeleteAll();
    }
  4. Next we need to clear the level 2 recycle bin i.e. at site collection level
    $Site.RecycleBin.DeleteAll();
  5. And lastly we need to dispose the SPSite object
    $Site.Dispose();
  That’s all you need to delete all items from recycle bin.