如何在 PowerShell 中清除回收站的内容?
powershellmicrosoft technologiessoftware & coding更新于 2026/2/14 22:52:17
Windows 操作系统中的回收站用于存储软删除的数据。软删除数据是指无法通过 (SHIFT + DEL) 按钮删除,而是直接通过 DEL 按钮删除的数据。每个本地磁盘都有各自配置的回收站空间。
要使用 GUI 删除回收站数据,只需右键单击并删除内容即可。
也可以使用 PowerShell 命令中的 Clear-Recyclebin cmdlet 删除回收站内容。此命令在 PowerShell 5 中引入,在较新版本中也可用。
示例
Clear-RecycleBin
输出
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"):
用户需要根据上述输出确认如何删除内容。
要删除特定驱动器的内容,您需要指定 –DriveLetter 参数。
Clear-RecycleBin -DriveLetter D
您也可以使用 –Force 参数在未经用户同意的情况下删除内容。
Clear-RecycleBin -Force
Clear-RecycleBin 不成功删除内容后不会生成任何输出。
要删除远程计算机的回收站内容,您需要使用远程命令。
例如:
Invoke-Command-ComputerNameTest-PC-ScriptBlock{Clear-RecycleBin-Force}
运行这些命令时,您需要确保远程 PowerShell 版本也为 5.0 或更高版本。

