Home » PowerShell Tips » PowerShell Empty Recycle Bin

PowerShell Empty Recycle Bin

Windows Recycle bin stores deleted contents, that you have deleted using Delete button ( and not Shift + Delete). Its easier to empty recycle bin using GUI ,right click on Recycle Bin folder and Delete it, it will remove all contents. However to empty recycle bin on local or remote computer , you will need PowerShell script to easy your task.

To empty recycle bin in PowerShell , use Clear-RecycleBin cmdlet. PowerShell Clear-RecycleBin command will clear the contents of recycle bin.

PowerShell Empty Recycle Bin
PowerShell Empty Recycle Bin

In this article, I will explain you how to empty recycle bin on local, empty recycle bin for specified drive using PowerShell.

PowerShell Clear-RecycleBin Syntax

Syntax

Clear-RecycleBin
     [[-DriveLetter] <String[]>]
     [-Force]
     [-WhatIf]
     [-Confirm]
     [<CommonParameters>]

PowerShell Empty All Recycle Bins

You can forcefully empty all recycle bins on local computer without asking user for confirmation to delete recycle bin content using Clear-RecycleBin cmdlet as below

Clear-RecycleBin -Force

In the above script, PowerShell Clear-RecycleBin uses Force parameter to remove contents of all recycle bin without user confirmation.

PowerShell Empty Recycle Bin

If you want to empty recycle bin on local computer, use below command

Clear-RecycleBin

Above command in PowerShell to empty all recycle bin on local computer ask for user confirmation to delete contents of recycle bin as below

PS C:\> Clear-RecycleBin

Confirm
Are you sure you want to perform this action?
Performing the operation "Clear-RecycleBin" on target "All of the contents of the Recycle Bin".
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help (default is "Y"): y

Upon Yes or yes to All consent, it will empty all recycle bin on local computer.

Cool Tip: How to convert decimal to hex in PowerShell!

PowerShell Empty Recycle Bin of Specified Drive

If you want to empty recycle bin of specified drive eg.. C:\, use Clear-RecycleBin command as below

Clear-RecycleBin -DriveLetter C

In the above script, PowerShell Clear-RecycleBin uses DriveLetter parameter to specify drive letter as C. It will ask for user confirmation to empty recycle bins of C Drive only.

Output of above command to delete recycle bin contents of specified drive as below

PS C:\> Clear-RecycleBin -DriveLetter C

Confirm
Are you sure you want to perform this action?
Performing the operation "Clear-RecycleBin" on target "All of the contents of the Recycle Bin for the 'C:\' drive".
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help (default is "Y"): y

PS C:\>

Cool Tip: How to stop running process in PowerShell!

Conclusion

In the above article, we have learned how to empty recycle bin using PowerShell script, empty all recycle bins on local computer.

PowerShell Clear-RecycleBin cmdlet clears the contents of recycle bin. You can delete content of specified drive using DriveLetter parameter.

You can find more topics about PowerShell Active Directory commands and PowerShell basics on ShellGeek home page.

Leave a Comment