# How to clear the content of the recycle bin in PowerShell?

PowerShellMicrosoft TechnologiesSoftware & Coding

Recycle bin in Windows operating system is to store the soft-deleted data. Soft deleted data means, data that is not deleted with (SHIFT + DEL) button but simply deleted with DEL button. Each local disk has its own configured recycle bin space.

To delete the recycle bin data using GUI, you can simply right click and delete the content.

It is also possible to delete the recycle bin content with the PowerShell command with the Clear-Recyclebin cmdlet. This command is introduced in PowerShell 5 and available in newer versions as well.

## Example

Clear-RecycleBin

## Output

PS C:\WINDOWS\system32> 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"):

User needs to confirm how the contents should be deleted as per the above output.

To delete the content of the specific drive, you need to specify –DriveLetter parameter.

Clear-RecycleBin -DriveLetter D

You can also delete the content without the user consent with the –Force parameter.

Clear-RecycleBin -Force

Clear-RecycleBin doesn’t generate any output on the successful deletion of contents.

To delete the recycle bin content of the remote computers, you need to use the remote commands.

For example,

Invoke-Command -ComputerName Test-PC -ScriptBlock{Clear-RecycleBin -Force}


You need to make sure that the remote PowerShell version is also 5.0 or higher while running these commands.

Updated on 16-Mar-2020 07:42:35