# Checks all drives on server (get-psdrive) and runs a loop # for all folders in that drive's recycle bin (:\$Recycle.Bin) # for any files that have been in the bin for more than 30 days --> AddDays(-30) # author - m8r ForEach ($Drive in Get-PSDrive -PSProvider FileSystem) { $Path = $Drive.Name + ':\$Recycle.Bin' Get-ChildItem $Path -Force -Recurse -ErrorAction SilentlyContinue | Where-Object { $_.LastWriteTime -lt (Get-Date).AddDays(-30) } | Remove-Item -Recurse }