Clear-RecycleBin | Taking on PowerShell one cmdlet at a time | Weekly Blog

Share this post:

This is a part of an on-going blog series written by Adam Gordon. Each week, Adam will walk you through a PowerShell command, showing you when and how to use each one. This week, Adam covers Clear-RecycleBin. 

When to use Clear-RecycleBin?

The Clear-RecycleBin cmdlet deletes the content of a computer’s recycle bin. This action is like using Windows Empty Recycle Bin.

*** This cmdlet was re-added in PowerShell 7.

What version of PowerShell am I using for this blog?

Get the PowerShell Version from your machine:

$PSVersionTable

This command shows you the PowerShell version information on your machine.

How to use Clear-RecycleBin?

Clear all recycle bins:

Clear-RecycleBin

Clear-RecycleBin prompts the user for confirmation to clear all recycle bins on the local computer.

Clear a specified recycle bin:

Clear-RecycleBin -Driveletter C

Clear-RecycleBin uses the –DriveLetter parameter to specify the recycle bin on the C volume.

The user is prompted for confirmation to run the command.

Clear all recycle bins without confirmation:

Clear-RecycleBin -Force

Clear-RecycleBin -Confirm:$false

Clear-RecycleBin uses the –Force parameter and does not prompt the user for confirmation to clear all recycle bins on the local computer.

*** An alternative is to replace -Force with -Confirm:$false

Learn last week’s command: Get-ComputerInfo.

Need PowerShell training? Check out ITProTV’s PowerShell online IT training courses.

Leave a Reply

Your email address will not be published. Required fields are marked *