In this article we show you how to empty the recycle bin using powershell and the Clear-RecycleBin cmdlet

Syntax

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

Parameters

-Confirm

Prompts for user confirmation before running the cmdlet. The user is prompted for confirmation even if the Confirm parameter isn’t specified.

-DriveLetter

Specifies the recycle bin to clear for a single drive letter or an array of drive letters.

-Force

Specifies that the user isn’t prompted for confirmation to clear a recycle bin. The Force parameter also overrides the WhatIf and Confirm parameters.

-WhatIf

Shows what would happen if Clear-RecycleBin runs. The cmdlet isn’t run.

Examples

 

Clear-RecycleBin

The cmdlet alone will clear all the local computer’s recycle bins. And you need to run it in an elevated PowerShell window.

You would see something like

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"):

With the -force switch, you can suppress the confirmation if you want to.

Clear-RecycleBin -Force

And if you only want to clean up the recycle bin on a certain drive, use the -DriveLetter switch

The user is prompted for confirmation to run the command.

Clear-RecycleBin -DriveLetter E