PowerShell Tip: Empty SharePoint Site Collection Recycle Bin

powershellSaving time, once again, with PowerShell

Have you ever ended up with a very large number of items in your SharePoint Site Collection recycle bin?

Sometimes, certain projects that involve migrations or large changes can fill up your bin with all of the items that didn’t make it to the next round.

More than likely, your recycle bin was similar to mine and only displays 50 items per page. For a recycle bin which contains thousands of items, I don’t have to do the math for you to realize that it would take a very long time to empty page by page.

This can happen for any number of reasons, but I’ll share how I ended up with such a large recycle bin and how I ultimately emptied the entire thing in just minutes.

How I overloaded my Recycle Bin:

I was recently performing a migration from WSS 2007 to SharePoint 2010 using our third-party migration tool, the Metavis Migrator.

During the migration, I ran into a few issues in regards to user mappings. Working with the fantastic Metavis Support Team, we resolved the issue and could successfully perform the migration again. But this particular site had a list with over 27,000 items in it, and because I had to attempt the migration of this site multiple times, I ended up with over 70,000 items in the recycle bin!

Like I said above, that would take a very, very long time only emptying 50 items at a time.

How did I empty the entire Recycle Bin?

One word – PowerShell.

Empty entire Site Collection Recycle Bin using PowerShell:

  1. Browse to the Start Menu. Search for “PowerShell”, select Windows PowerShell ISE. (I am running Windows 2012 in this example. The steps to open PowerShell ISE may differ if using another Operating System). Select PowerShell
  2. Copy the below command into PowerShell. Update the Site Collection URL to match the appropriate site.
 $sitecollectionUrl = “http://domainname.com/sitecollectionurl”$siteCollection = New-Object Microsoft.SharePoint.SPSite($sitecollectionUrl)write-host(“Items to be deleted : ” +$siteCollection.RecycleBin.Count.toString())$now = Get-Datewrite-host(“Deleting started at ” +$now.toString())$siteCollection.RecycleBin.DeleteAll();$now = Get-Date

write-host(“Deleting completed at ” +$now.toString())


  1. Once you have updated the Site Collection URL, execute the command by clicking on the Run Script button on the PowerShell toolbar. PowerShell toolbar run script

Depending on how many items are in the recycle bin, this could take a few minutes. When the command is executing, the red stop button (two to the right of the Run Script button) will be illuminated. When the command is completed, the Run Script button will be illuminated once again.

When the command is completed, you can verify if it was successful. Chances are, if the command did not display any errors, all items have been deleted. Simply browse to the appropriate SharePoint site to determine if the Site Collection recycle bin is now empty.

As stated above, the recycle bin I was working with had approximately 70,000 items. I executed the command, knowing it would take some time. I checked back about 20 minutes later and it was completed. An easy way to check progress is by monitoring the recycle bin while the command is executing. You will be able to refresh the page and watch the number of items decrease.

That’s it! Please comment below with any questions.

2014-05-29T08:30:29+00:00 May 29th, 2014|


  1. Meen Bamm August 12, 2014 at 6:28 am - Reply

    Can you give the powershell command to restore all items in recycle bin with days to choose. I search Google and the command I found doesn’t work.

    This is what I used.

    $recyclebinitems = (Get-SPWeb “_http://” ).RecycleBin foreach($recyclebinitem in $recyclebinitems)
    (Get-SPWeb “_http://”).RecycleBin.Restore($recyclebinitem.ID)

    The above command seems to be missing something..

    Thank you..

  2. Will December 13, 2014 at 6:31 am - Reply

    Any reason why you’re using new-object instead of Get-SPSite to instantiate the site?

  3. miroslaw_ziolkowski January 2, 2015 at 4:50 am - Reply

    This one works for deletion:
    $recyclebinitems = (Get-SPSite “http://”).RecycleBin
    foreach($recyclebinitem in $recyclebinitems)
    (Get-SPSite “http://”).RecycleBin.Delete($recyclebinitem.ID)

  4. Andrey February 3, 2016 at 3:56 am - Reply

    Hi, Joe!
    In your example you use Win Powershell ISE. However, by default your script wouldn’t work, because it doesn’t have a link to SharePoint snap-in.
    May be you add to the 1st line of your code:
    Add-PSSnapin “Microsoft.SharePoint.PowerShell”

    It would be more esier for readers to use it.

Leave A Comment