Clear Recycle Bin using PowerShell

In PowerShell, starting with Version 5, we can use cmdlet Clear-RecycleBin to clear recycle bin using PowerShell.

By default, the behavior is to clear all files and a prompt asking for confirmation:

 

Clear recycle bin cmdlet default behavior
Clear recycle bin cmdlet default behavior

We can use -Confirm:$False switch to stop prompting. Also if we want to restrict file deletion from a particular drive, we can use cmdlet to specify drive also:

Clear-RecycleBin -Confirm:$False -DriveLetter C:

Do note that you need to have PowerShell prompt to be running in admin mode for this to work.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s