Skip to content

Instantly share code, notes, and snippets.

@lanekatris
Last active January 31, 2018 01:40
Show Gist options
  • Save lanekatris/46943cf60586c4b061b00f74a6bcf4ac to your computer and use it in GitHub Desktop.
Save lanekatris/46943cf60586c4b061b00f74a6bcf4ac to your computer and use it in GitHub Desktop.
Run like this:
# .\test.ps1 -path c:\temp
param (
[Parameter(Mandatory=$true)]
[string]$path,
[string]$folderName = "references"
)
Write-Host "Looking for folders with the name $folderName here: $path"
$folders = Get-ChildItem -Path $path -Filter $folderName -Recurse -Directory
$count = $folders.Length
Write-Host "Found $count folders with the name $folderName. Here are their paths: "
write-host "==================="
Write-Host ""
foreach ($folder in $folders) {
Write-Host $folder.FullName
}
Read-Host "Want to delete them? [enter WILL DELETE]"
$folders | Remove-Item -Force -Recurse
Write-Host ""
write-host "==================="
write-host "Done"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment