8
0

14 lines
1.4 KiB
PowerShell
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

Set-Variable -Name TargetPath -Value "e:\test1" -Scope Local -Force
Set-Variable -Name TargetPathList -Value $NULL -Scope Local -Force
Clear-Host
DO {
$TargetPathList = gci $TargetPath -directory -recurse -ErrorAction SilentlyContinue | Where { (gci $_.fullName -ErrorAction SilentlyContinue).count -eq 0 } | select -expandproperty FullName -ErrorAction SilentlyContinue
$TargetPathList | Foreach-Object {
Write-Host "This empty Folder will be deleted: $_ "
Remove-Item $_ -Force -ErrorAction SilentlyContinue
} #end DO
} while ($TargetPathList.count -gt 0)
Remove-Variable -Name TargetPath -Force -ErrorAction SilentlyContinue
Remove-Variable -Name TargetPathList -Force -ErrorAction SilentlyContinue