Do you need to create a list table showing the size of each user’s recycle bin and then a total of all the disk space used on Recycle Bins? Well if so, this is the article for you!
$totalSize = 0
Get-ChildItem 'C:\Users\' -Directory | ForEach-Object {
$user = $_.Name
$size = [math]::Round((Get-ChildItem $_.FullName -File -Force -Recurse -ErrorAction SilentlyContinue | Measure-Object -Property Length -Sum).Sum / 1GB, 2)
$totalSize += $size
[PSCustomObject]@{
User = $user
SizeGB = $size
}
}
..and if you need a total for all users Recycle Bins, you can either tack this on the end of the PowerShell script above, or you can run it separately after:
[PSCustomObject]@{
User = "Total"
SizeGB =
[math]::Round($totalSize, 2)
}
This website uses cookies.