Link to home
Start Free TrialLog in
Avatar of michalek19
michalek19Flag for United States of America

asked on

Script to audit and clean Recycle Bin on bulk of servers

Hi

I am looking for script to run against few servers that will provide inventory (content) and size  of the recycle bin.
The second part of the script should empty out\clean  recycle bins  

Please assist, M
Avatar of Jason Crawford
Jason Crawford
Flag of United States of America image

As far as I know there is no way to empty the recycle bin of another user.  PowerShell 5 includes a native cmdlet for emptying your own recycle bin - Clear-RecycleBin, and Jaap Brasser wrote a script to gather the contents available here:

http://www.jaapbrasser.com/clear-recyclebin-new-powershell-5-0-cmdlet-available-in-windows-10/
To clear Recycle bin for all users, you can start the following command with PSEXEC
(Or you can do folder delete command via VBS or Powershell)

PSEXEC Command
PSEXEC -C -F -D \\SomeServer CleanBin.bat

Open in new window


CleanBin.bat
ECHO OFF
RD /S c:\$Recycle.Bin /Q

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Shaun Vermaak
Shaun Vermaak
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of michalek19

ASKER

I created my own script that provide me need it information. Thank you
My script in ID42002838 works
User generated image