loonison101
1/31/2018 - 1:39 AM

Run like this:

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"