function Get-Tree($Path,$Include='*') { @(Get-Item $Path -Include $Include -Force) + (Get-ChildItem $Path -Recurse -Include $Include -Force) | sort pspath -Descending -unique } function Remove-Tree($Path,$Include='*') { Get-Tree $Path $Include | Remove-Item -force -recurse } Remove-Tree O:\DFS\visualblind get-childitem O:\DFS\visualblind -Recurse -ErrorAction STOP