-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathclean.ps1
More file actions
27 lines (23 loc) · 708 Bytes
/
clean.ps1
File metadata and controls
27 lines (23 loc) · 708 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# Don't allow using undeclared variables
Set-Strictmode -version latest
$root = "$PSScriptRoot"
Write-Host -Foreground Blue "Delete dirs: bin, obj"
[int]$deleteCount = 0
[array]$failedToDeleteDirs = @()
Get-ChildItem $root -Include bin,obj -Recurse -Force | %{
Remove-Item -Recurse -Force -ErrorAction SilentlyContinue $_.FullName
if ($?) { $deleteCount++ }
else {
$failedToDeleteDirs += $_
}
}
Write-Host -Foreground Green "Deleted $deleteCount folders."
if ($failedToDeleteDirs) {
$failCount = $failedToDeleteDirs.Count
Write-Host ""
Write-Host -Foreground Red "Failed to delete $failCount dirs:"
$failedToDeleteDirs | %{
Write-Host -Foreground Red $_.FullName
}
exit /B 1
}