14 lines
1.4 KiB
PowerShell
14 lines
1.4 KiB
PowerShell
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 |