When looking around for an easy way to clean up servers and the accounts that use the servers I wanted a way to clear the Recycle Bins for all users. Consultants leave a lot of crap around on servers apparently. However because we use various versions of PowerShell there are various methods of doing so.
Here are a few methods that you can use.
The first solution:
Get-ChildItem -Path 'C:\$Recycle.Bin' -Force | Remove-Item -Recurse -ErrorAction SilentlyContinue
The second solution:
$recycleBin = (New-Object -ComObject Shell.Application).NameSpace(0xa)
$recycleBin.Items() | ForEach-Object -Process { Remove-Item -Path $_.Path -Force -Recurse }
The third solution (preferred but only works on PowerShell V5 and newer)
Clear-RecycleBin -Force