Last active
August 23, 2017 06:15
-
-
Save dbrack/8afef731db86f1de06e7 to your computer and use it in GitHub Desktop.
Power shell script to find empty folders in a given path.
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
# to run this script, execute .\EmptyFolders.ps1 -path "path\to\search" -output "path\to\outputfile.txt" | |
# if output is not supplied, the file is created in the current working directory | |
# | |
# to run unsigned powershell scripts that were created on your local computer, run the following command in PowerShell (Run as administrator) | |
# set-executionpolicy remotesigned | |
# | |
# to completly disable signture checks, run | |
# set-executionpolicy unrestricted | |
param ( | |
[string]$path = "", | |
[string]$output = "$pwd\output.txt" | |
) | |
write-output "Checking $path for empty folders..." | |
$out = (Get-ChildItem $path -recurse | Where-Object {$_.PSIsContainer -eq $True}) | Where-Object {$_.GetFiles().Count -eq 0} | Select-Object FullName | |
$out >> $output | |
write-output "wrote output to $output" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment