Clear SharePoint Site’s Recycle Bin using PowerShell Script

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.

Comments

Popular posts from this blog

Installation and Configuration of Office Online Server with SharePoint 2019

Workflow Manager 1.0- Installation, Configuration and Issues

SharePoint 2019 Upgrade Part 6: SharePoint Upgrade Issues