Here’s a fast & furious tip on using PowerShell to find out how much is in the Recycle bin. All you should need to do is use Get-ChildItem to enumerate the Recycle folder. By default it is hidden so you need to use the -Force parameter. To get the total size of all the files, simply run this:
PS E:\ > Get-ChildItem c:\recycler -force -recurse | measure length -sum
Count : 42
Average :
Sum : 72133693
Maximum :
Minimum :
Property : length
I can see there are 42 files taking up 72133693 bytes of space. I can also use this to check remote systems as well:
Get-ChildItem \dc01\c$\recycler -force -recurse | measure length -sum
If you want a cleaner one liner, try this:
“{0:N2}” -f ((Get-ChildItem e:\recycler -force -recurse | measure length -sum ).sum/1mb)
This will display the sum, formatted to two decimal points in MB.
Another great idea !, I like especially the code which is looking for remote recycle bin.
This is something I would certainly want to test in a non production environment. I also see that there is a slight typo. The remote computer expression should be this:
Get-ChildItem \\dc01\c$\recycler -force -recurse | measure length -sum
Code sometimes gets a little hosed when uploading blog entries.