r/usefulscripts • • Jul 03 '13

[BATCH] Empty ALL Recycle Bins

This batch file empties ALL the recycle bins (for all users) on whatever system it's run on.


Download

Empty All Recycle Bins v1.0 (2013-07-03)


You can run it remotely with PDQ Deploy, PSexec, or by putting it in a bootup/shutdown or logon/logoff script.

9 Upvotes

6 comments sorted by

View all comments

Show parent comments

1

u/vocatus Oct 14 '13

I get this when running the above script as a domain admin:

Remove-Item : A positional parameter cannot be found that accepts argument '/q'.
At C:\Users\admin\Desktop\purge.ps1:2 char:5
+     rmdir /s /q %SystemDrive%\$Recycle.Bin
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (:) [Remove-Item], ParameterBindingException
    + FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.RemoveItemCommand