Share this post:This blog post is part of an ongoing series by Adam Gordon. Adam will guide you through a PowerShell command each week, explaining when and how to use them. This week Adam will be covering Clear-RecycleBin.
Clear-RecycleBin: When should you use it?
Clear-RecycleBin deletes the contents of a computer’s recycle bin. This is similar to using Windows Empty Recycle Bin.
*** This cmdlet has been re-added to PowerShell 7.
What version of PowerShell should I use for this blog?
Get the PowerShell Version for your machine
$PSVersionTable
This command displays the PowerShell version information for your machine.
Clear-RecycleBin: How do you use it?
All recycle bins must be empty
Clear-RecycleBin
Clear-RecycleBin prompts users to confirm that they want to empty all recycle bins from their local computer.
Clear out a designated recycle bin
Clear-RecycleBin Driveletter C
Clear-RecycleBin uses -DriveLetter to specify the recycle bin for the C volume.
The user will be prompted to confirm that they wish to execute the command.
All recycle bins must be empty without confirmation
Clear-RecycleBin -Force
Clear-RecycleBin -Confirm:$false
Clear-RecycleBin uses a -Force parameter, and does not prompt users to confirm that they have cleared all recycle bins on their local computers.
*** You can also replace -Force by -Confirm.$false
Get-ComputerInfo reveals the command last week.
Do you need PowerShell training? ITProTV offers PowerShell online IT training courses.