Public/Remove-Folder.ps1
# Remove-Folder C:\src\Beispiele @("node_modules", "npm-cache") function Remove-Folder { Param( [string]$Path = $pwd, [Parameter(Mandatory = $true)] [string[]]$Names ) $childs = Get-ChildItem $Path foreach ($item in $childs) { if ($item -is [System.IO.DirectoryInfo]) { $curDir = Join-Path $Path $item # $_ is the piped item value of $Names if ($Names | Where-Object { $item.Name -eq $_ }) { Remove-Item –path $curDir -Recurse -Force Write-Host $curDir } else { DeleteFolder $curDir $Names } } } } |