Tip: You can empty the recycle bin:
1 2 3 4 5 6 7 8 9 |
# Solution 1 Get-ChildItem -Path 'C:\$Recycle.Bin' -Force | Remove-Item -Recurse -ErrorAction SilentlyContinue # Solution 2 $recycleBin = (New-Object -ComObject Shell.Application).NameSpace(0xa) $recycleBin.Items() | ForEach-Object -Process { Remove-Item -Path $_.Path -Force -Recurse } # Solution 3 (PowerShell v5) Clear-RecycleBin -Force |
Pingback: Powershell Tip #75: List only hidden files in a folder | Powershell Guru
Clear-RecycleBin -Force if you don’t want the prompt.
The path can be a local drive or network drive..
To view their sizes
Get-ChildItem C:\ -Directory -Hidden -Filter ‘$REC*’ -Recurse | Select-Object Name,FullName,@{l=”Size in MB”;e={“{0:N2}” -f ((Get-ChildItem $_.FullName -Force | Measure-Object -Property length -sum).sum / 1MB)}}
—————————————————————————————————–
To remove ALL $Recycle.bin folders
Get-ChildItem C:\ -Directory -Hidden -Filter ‘$REC*’ -Recurse|Remove-Item -Force -Recurse