Clear-RecycleBin

清除当前用户的回收站的内容。

语法

All

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

说明

此 cmdlet 仅在 Windows 平台上可用。

Clear-RecycleBin cmdlet 删除当前用户的回收站的内容。 此操作类似于使用 Windows 空回收站

此 cmdlet 在 PowerShell 7 中读取。

示例

1:清除所有回收站

在此示例中,清除所有驱动器的当前用户的回收站。

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

Clear-RecycleBin 提示用户进行确认。

2:清除指定的回收站

此示例清除指定驱动器号的回收站。

Clear-RecycleBin -DriveLetter C

Clear-RecycleBin 使用 DriveLetter 参数指定 C 卷上的回收站。 系统会提示用户确认以运行命令。

3:在未确认的情况下清除所有回收站

此示例不提示确认清除回收站。

Clear-RecycleBin -Force

Clear-RecycleBin 使用 Force 参数,并且不会提示用户确认以清除所有回收站。

替代方法是将 -Force 替换为 -Confirm:$false

参数

-Confirm

在运行 cmdlet 之前提示用户确认。 即使未指定 Confirm 参数,也会提示用户进行确认。

参数属性

类型:SwitchParameter
默认值:False
支持通配符:False
不显示:False
别名:cf

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-DriveLetter

指定要清除单个驱动器号或驱动器号数组的回收站。

参数属性

类型:

String[]

默认值:None
支持通配符:False
不显示:False

参数集

(All)
Position:0
必需:False
来自管道的值:False
来自管道的值(按属性名称):True
来自剩余参数的值:False

-Force

指定不会提示用户确认清除回收站。 Force 参数还替代 WhatIfConfirm 参数。

参数属性

类型:SwitchParameter
默认值:None
支持通配符:False
不显示:False

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-WhatIf

显示 Clear-RecycleBin 运行时会发生什么情况。 cmdlet 未能运行。

参数属性

类型:SwitchParameter
默认值:False
支持通配符:False
不显示:False
别名:无线

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

CommonParameters

此 cmdlet 支持通用参数:-Debug、-ErrorAction、-ErrorVariable、-InformationAction、-InformationVariable、-OutBuffer、-OutVariable、-PipelineVariable、-ProgressAction、-Verbose、-WarningAction 和 -WarningVariable。 有关详细信息,请参阅 about_CommonParameters

输出

None

此 cmdlet 不返回任何输出。

备注

此 cmdlet 仅在 Windows 平台上可用。