Jump to content

Recommended Posts

Posted

Hi folks,

 

We are running a 2008 R2 file server, on which are the students home folders.

 

We spotted that when students were deleting files/folders, on their Win 7 clients, that the files/folders were going into the file server's recycle bin. The students local recycle bins weren't showing anything though, so this was ultimately pointless. We then used group policy to turn off the recycle bin usage, and to delete files immediately.

 

Whether this is related or not, as we migrated file servers last summer, I've spotted a $RECYCLE.BIN folder in many if not all of the students home folders. These folders can have hundreds of MBs of files in. If I browse to them with Windows Explorer the folders appear empty (yes, hidden/system files are turned on), but it's via the wonderful TreeSize that I've spotted the files/folders are there, and TreeSize will delete them.

 

The problem is that there are hundreds of these folders, so does anyone know a file explorer type tool that can (a) identify these recycle bin folders on mass e.g. via a search and (b) then delete them?

 

TIA

Posted
So just to double check, it can search by folder name on mass, and delete on mass?

 

Both, yes. We use it here regularly to search for and delete 'Recycler' folders.

  • Thanks 1
Posted

I'd like to know more on this. It's def' the Win 7 Clients as we have home folders on Server 2003. We also run Ranger for Networks, but that does not seem to be the cause or the solution. Their suggestion was to find and delete the $RECYCLE.BIN that are being created in Ranger folders due to the redirection of pupil desktops, start menu, favourites etc. to the ranger folders. They also suggested permissions on the folders, but the Ranger folders are not supposed to be full perm' for pupils otherwise they'd be writing/ deleting.

Any Ideas, anyone?

:(

Posted

localzuk: Thanks!

 

CadlaM: We also use Ranger, although these folders are created within the home folders, which aren't directed to using Ranger.

Posted

You can use powershell on your file server and run the following in the root of your home drives folder:

 

$recycleBins = Get-ChildItem "$RECYCLE.BIN" -Recurse -Force
foreach ($recycleBin in $recycleBins) { $recycleBin.Delete($true) }

  • Thanks 2
Posted
I can't verify this right now but I remember just disabling the recycle bin on the drive that the folder shares are on. Have to double check later.

It's been disabled via Group Policy now, but the bigger issue are all the remaining system folders that Explorer won't let me browse.

 

Thanks to all those with the suggestions for deleting. Much appreciated!

Posted

On your file server, navigate to Control Panel > Folder Options > View, untick Hide protected operating system files (recommended)

 

Navigate to a user home directory and at the top right search for recycle

 

You can then delete all this and the system will re-create them (as standard).

 

By enabling the GPO: User Config > Policies > Admin Templates > Windows Components > Windows Explorer - Do not move deleted files to the Recycle Bin - Enabled this will stop your server quickly filling up!

 

Remember to re-tick Hide protected operating system files (recommended) when you're done ;)

  • Thanks 3
Posted
On a related issue, if ever you get users with a corrupt Recycle bin message (on logon) the above method works too to resolve this error.
  • Thanks 1
Posted

I hadn't though to just search for the folders and delete them, versus trying to open all said folders and then delete the contents. Doh!

 

I did try TreeSize Professional, which accidentally helped me spot about 25GB of Cert 18 films, but couldn't figure out how to find folders with it. Files were easy. It doesn't help that this is a file server with 2 million files in the home folder directory :-/ JAM Software does have a free file search tool which looks to be that particular part of TreeSize Professional, plus also a free PC stress testing tool, albeit also a side issue :-)

  • 2 weeks later...
Posted
You can use powershell on your file server and run the following in the root of your home drives folder:

 

$recycleBins = Get-ChildItem "$RECYCLE.BIN" -Recurse -Force
foreach ($recycleBin in $recycleBins) { $recycleBin.Delete($true) }

 

Is this code correct, it doesnt seem to work for me. Thanks

Posted
By enabling the GPO: User Config > Policies > Admin Templates > Windows Components > Windows Explorer - Do not move deleted files to the Recycle Bin - Enabled this will stop your server quickly filling up!

 

;)

 

Michael,

No problem deleting errant recycle bins, but, before I do the (sensible looking ) GPO change... On my system, Server 2003/WIn XP AD with Ranger For Networks, we never see the recycle bin on the desktop. I am guessing that this is surpressed by Ranger.

 

Or is this normal on a vanilla system too? Anyone?

 

We have "Previous Versions" and daily backups, so Dusty Bin is not missed by anyone.

 

On Win 7 with Ranger I don't see the Recycle bin on Desktop, but Win keeps creating them on every new logon to 7 in the ranger desktop/favorites/cookies redirected folders.

So I think your GPO fix with stop that with 7.

Posted

To hide the Recycle Bin on the desktop, you enable the policy - User Config > Policies > Admin Templates > Desktop - Remove Recycle Bin icon from desktop - Enabled and/or Hide and disable all items on the desktop (optional).

 

I suspect it is the same/similar with Ranger, although I cannot be 100% as I don't use it.

 

The Recycle Bins in Windows 7 will still be created (in each redirected folder), they just won't be used, but they should be hidden from the end user anyway.

  • 4 weeks later...
Posted
On your file server, navigate to Control Panel > Folder Options > View, untick Hide protected operating system files (recommended)

 

Navigate to a user home directory and at the top right search for recycle

 

You can then delete all this and the system will re-create them (as standard).

 

By enabling the GPO: User Config > Policies > Admin Templates > Windows Components > Windows Explorer - Do not move deleted files to the Recycle Bin - Enabled this will stop your server quickly filling up!

 

Remember to re-tick Hide protected operating system files (recommended) when you're done ;)

 

Thanks for this, just done it and it worked perfectly.

 

One problem I had was with files over the 255 character limit but a little renaming fixed those as well.

  • 11 months later...
Posted
You can use powershell on your file server and run the following in the root of your home drives folder:

 

$recycleBins = Get-ChildItem "$RECYCLE.BIN" -Recurse -Force
foreach ($recycleBin in $recycleBins) { $recycleBin.Delete($true) }

 

This code does not appear to work for me. Is it definitley correct? I can see lots of $RECYCLE.BIN folders in all of the students home folders that I need to remove. I've now corrected not to use the recycle bin in gpo but still need to delete the existing folders and contents.

 

Thanks, Ed

  • 4 months later...
Posted

As others have mentioned there is a little error in the PowerShell code.

$recycleBins = Get-ChildItem "$RECYCLE.BIN" -Recurse -Force
foreach ($recycleBin in $recycleBins) { $recycleBin.Delete($true) }

 

"$RECYCLE.BIN" should be '$RECYCLE.BIN' otherwise the folder gets interpreted as a variable.

 

I've just used this and it flew through the data getting rid of GBs of recycled data almost instantly

Get-ChildItem -Path '$Recycle.bin' -recurse -force |Remove-Item -recurse -force

 

As usual, test yourselves first on some practice data.

 

Cheers.

  • Thanks 1
  • 1 month later...
Posted

Our users seem to have several $Recycle.bin folders e.g. for the home folder Z: we have

four recycle bins under

Z:\

Z:\My Music

Z:\My Pictures

Z:\My Videos

 

Is this normal ? I guess I need to delete all four to clean up ?

  • 1 month later...
  • 3 years later...
  • 2 years later...
Posted
As others have mentioned there is a little error in the PowerShell code.

$recycleBins = Get-ChildItem "$RECYCLE.BIN" -Recurse -Force
foreach ($recycleBin in $recycleBins) { $recycleBin.Delete($true) }

 

"$RECYCLE.BIN" should be '$RECYCLE.BIN' otherwise the folder gets interpreted as a variable.

 

I've just used this and it flew through the data getting rid of GBs of recycled data almost instantly

Get-ChildItem -Path '$Recycle.bin' -recurse -force |Remove-Item -recurse -force

 

As usual, test yourselves first on some practice data.

 

Cheers.

 

sorry to necro an old thread but I've taken over an old fileserver that has this issue.

 

So far the only solution I've found Is the above command, but it only does the top level recycle bin, none of the others in 'my pictures' etc.

 

Does anyone know what snippet of code I'm missing? I thought -Recurse would do it, but apparantly not.

 

Regards,

  • Thanks 1
Posted

Hi Warwick_Tech,

Only just seen this. Yeah, there is a problem in my original line there that was introduced by my auto-formatting tool (ISE Steroids). That 'path' is wrong so something like this should work instead:

 

$Path = 'E:\Teaching Staff\Work'
Get-ChildItem -Path $Path -Include '$Recycle.bin' -Recurse -Force  -ErrorAction SilentlyContinue | Remove-Item -Recurse -Force

 

That post was from 2013 though, and if you're not embarrassed by your scripts 6 months later then you're not progressing. I would do things a lot differently these days so let me have a play and try to post something more advanced later.

  • Thanks 1

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...