Clear-Directory.ps1
function Clear-Directory { param ( [Parameter(mandatory)][String]$dir, [String[]]$Exceptions=@(), [Switch]$Feedback ) $DeleteTheseFiles = Get-ChildItem -Path $dir | Where-Object name -NotIn $Exceptions foreach ($file in $DeleteTheseFiles) { if ($Feedback) { Write-Host "CLEANING... $($file.fullname) ... " -NoNewline -BackgroundColor Black -ForegroundColor Yellow } Remove-Item -Path $file.fullname -Force -Recurse if ($Feedback) { Write-host 'Cleaned!' -BackgroundColor Black -ForegroundColor Green } } } |