Gongalong Posted March 7, 2012 Posted March 7, 2012 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
localzuk Posted March 7, 2012 Posted March 7, 2012 Treesize Pro can handle this, but it isn't free. 1
Gongalong Posted March 7, 2012 Author Posted March 7, 2012 So just to double check, it can search by folder name on mass, and delete on mass?
localzuk Posted March 7, 2012 Posted March 7, 2012 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. 1
CadlaM Posted March 7, 2012 Posted March 7, 2012 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?
Gongalong Posted March 7, 2012 Author Posted March 7, 2012 localzuk: Thanks! CadlaM: We also use Ranger, although these folders are created within the home folders, which aren't directed to using Ranger.
FN-GM Posted March 7, 2012 Posted March 7, 2012 (edited) This maybe of use - http://www.edugeek.net/forums/windows/44134-redirected-my-documents-recycler.html#post406010 You could put this in a batch file as a logoff / Logon script. It will remove the $RECYCLE.BIN folder. Just change the drive letter to the letter you use for home areas. rmdir /s /q "H:\$RECYCLE.BIN" Edited March 7, 2012 by FN-GM 3
ChrisMiles Posted March 7, 2012 Posted March 7, 2012 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) } 2
chazzy2501 Posted March 7, 2012 Posted March 7, 2012 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.
Gongalong Posted March 7, 2012 Author Posted March 7, 2012 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!
Michael Posted March 10, 2012 Posted March 10, 2012 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 3
Michael Posted March 10, 2012 Posted March 10, 2012 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. 1
Gongalong Posted March 12, 2012 Author Posted March 12, 2012 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 :-)
FN-GM Posted March 25, 2012 Posted March 25, 2012 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
CadlaM Posted March 26, 2012 Posted March 26, 2012 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.
Michael Posted March 26, 2012 Posted March 26, 2012 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.
zag Posted April 23, 2012 Posted April 23, 2012 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.
eddyc Posted April 8, 2013 Posted April 8, 2013 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
eejit Posted September 6, 2013 Posted September 6, 2013 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. 1
mrstrong Posted October 22, 2013 Posted October 22, 2013 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 ?
mrstrong Posted November 29, 2013 Posted November 29, 2013 deleted all four and seemed to do the trick with no adverse effects
Sagima Posted December 12, 2016 Posted December 12, 2016 Did this for the first time ever. 1410GB freed on the fileserver (turned off recycle bins in group policy now)
Warwick_Tech Posted October 8, 2019 Posted October 8, 2019 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, 1
eejit Posted October 16, 2019 Posted October 16, 2019 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. 1
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now