0

Is there a way to show the size of a recycle bin for each user in Windows Server 2019?

(Or, perhaps, calculate such sizes via PowerShell and then display them in a neat table?)

We may have runaway processes or applications flooding the recycle bin and consequently, the disk:

TreeSize - space taken by recycle bins

"Disk Cleanup" doesn't seem to be of much use: seems to only show the current user's recycle bin's size:

Windows Disk Cleanup

Running something like this on the target server:

(Get-ChildItem -LiteralPath 'C:\$Recycle.Bin' -File -Force -Recurse -ErrorAction SilentlyContinue |
    Measure-Object -Property Length -Sum).Sum

... will get me the total size of the recycle bin but:

  • does not expose ownership
  • seems to take forever, in some cases > 12 hours, at which point I have to stop it as the servers run production workloads.

What is the best way to get a table where file and folder owners are displayed along with total size of files and folders they own, for all user's recycle bins on a server's C: drive?

user      directory     size
---       ---
sergio    recycle bin    20GB
rene      recycle bin     1GB
spunky    recycle bin   100GB
system    recycle bin   300TB
admin     recycle bin    10GB
4
  • 2
    Is it always S-1-5-18? That's always the SID of "LocalSystem"; I'm not sure whether a detailed table would reveal much of use. Commented Aug 8, 2023 at 18:37
  • so far across two similar configured servers - yes, S-1-5-18. A table might still be of use - to confirm the SID is responsible for the bulk of Recycle Bin size across a number of servers, and potentially to automate the cleanup Commented Aug 8, 2023 at 18:47
  • Sounds like you need to set that account if not all accounts to not send to the recycle bin on this system rather than trying to cleanup after the fact, just prevent it from being saved to the Recycle bin entirely. Either per account or per all account as mentioned here with the correlated registry keys: itprotoday.com/compute-engines/q-how-can-i-disable-recycle-bin Commented Jan 12 at 3:47
  • both (done back in August) Commented Jan 12 at 16:32

0

You must log in to answer this question.