Purge Recycle Bin

The other day I showed how to find out how much space was being used by the recycle bin. To clear the folder you can use an expression that takes the result of Get-Child-item and pipes it to Remove-Item.  Here’s an example:

Get-ChildItem e:\temp\testme -recurse | remove-item -recurse -whatif

I’m using the -WhatIf parameter so verify what would happen. This is a good habit when performing destructive operations. You may need to use -force to overcome any restrictions like a read-only file. You still need permission to delete the file.  Using -force won’t change any permissions.

Because the Recycle folder is hidden, you’ll want to use an expression like this:

Get-ChildItem c:\recycler -force -recurse | remove-item -recurse -force -whatif

This will show what will be deleted. To carry out the dirty deed:

Get-ChildItem c:\recycler -force -recurse | remove-item -recurse -force

You might see an error message about failing to find part of a path, but you should be able to ignore this message. I strongly encourage you to test all of this on a non-production system so that you thoroughly understand how these cmdlets and expressions work.