Created
August 21, 2015 10:08
-
-
Save AlexKasaku/da82ab80d0cb3f782444 to your computer and use it in GitHub Desktop.
Removes empty folders
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
.SYNOPSIS | |
Removes empty folders | |
#> | |
filter NoChildren { | |
if ($_.Children.Count -eq 0) { | |
$_ | |
} | |
} | |
$itemsToRemove = Get-ChildItem -Recurse | Where TemplateName -eq "Redirect Folder" | NoChildren | |
foreach( $item in $itemsToRemove ) { | |
Write-Host $item.FullPath | |
$item | Remove-Item | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment