Last active
August 14, 2020 15:18
-
-
Save dulldesk/4529497dd9f10c8f68d7d4dd4cf9599a to your computer and use it in GitHub Desktop.
PowerShell script to check the current user's recycle bin size
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Write-Host $env:username 'Recycle Bin size' -fore cyan | |
$sid = (gwmi win32_useraccount | ? {$_.name -eq $env:username}).SID | |
$sm = (ls -recurse ("C:\`$recycle.bin\$sid") -force -EA SilentlyContinue | measure -property length -sum).sum | |
Write-Host ($sm / 1GB) "GB" | |
Write-Host ($sm / 1MB) "MB" | |
Write-Host " " | |
pause | |
<# | |
calculate size (in bytes) in 1 line: | |
(ls -recurse -force -EA SilentlyContinue ("C:\`$recycle.bin\$((gwmi win32_useraccount | ? {$_.name -eq $env:username}).SID)") | measure -property length -sum).sum | |
#> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To check the size for all accounts:
Values are in bytes.
Some may not appear due to user file permissions.