tools/Empty-RecycleBins.ps1
Function Empty-RecycleBins { <# .SYNOPSIS This script will empty all $RECYCLE.BIN files on the selected volume .NOTES Name: Empty-RecycleBins Author: Elliott Marter .EXAMPLE Empty-RecycleBins -Volume D: .LINK https://www.powershellgallery.com/profiles/elliottmarter #> [CmdletBinding(SupportsShouldProcess)] param( [Parameter( Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, Position = 0 )] [string[]] $Volume ) BEGIN { $Bins = (Get-ChildItem -Path $Volume`: -Recurse -Force -Filter '$RECYCLE.BIN').FullName } PROCESS { foreach ($b in $Bins ) { Get-ChildItem -Path $b -Force -Recurse | Remove-Item -Force -Recurse -Verbose } } END {} } |