Quickly Empty Recycle Bin With PowerShell

By James|10/25/2017|,

Introduction

I was doing some site cleanup today and ended up with around 15,000 items in a site collection recycle bin.  I started cleaning them out using the GUI.  It was SLOW going.  There is no way to "Delete All" for the second stage bin.  Rather, you have to delete items from the second stage bin one page of items at a time.  Here's a quick tip on how to delete everything with PowerShell.

Empty Recycle Bin

The following code will delete EVERYTHING out of both stages of the site collection recycle bin:

$site = Get-SPSite http://your.portal.url/site_collection
Write-Host "Items in recycle bin:" $site.RecycleBin.Count
$site.RecycleBin.DeleteAll()

The amount of time the DeleteAll() process takes to complete will depend on how many items are being removed.  Enjoy!

 

Copyright 2011 - 2024 The Lazy IT Admin | All Rights Reserved
menu-circlecross-circle linkedin facebook pinterest youtube rss twitter instagram facebook-blank rss-blank linkedin-blank pinterest youtube twitter instagram