-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCleanup.ps1
27 lines (23 loc) · 922 Bytes
/
Cleanup.ps1
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
function Remove-SpecialDirectories {
param (
[string]$RootPath,
[string]$DirName
)
# Get all directories matching the name, including hidden ones.
$Directories = Get-ChildItem -Path $RootPath -Directory -Recurse -Force |
Where-Object {
$_.Name -eq $DirName -and
$_.FullName -notlike '*node_modules*'
}
foreach ($Dir in $Directories) {
Write-Output "Deleting directory: $($Dir.FullName)"
# Remove the directory and its contents.
Remove-Item -Path $Dir.FullName -Recurse -Force -ErrorAction SilentlyContinue
}
}
# Starting path for the search (current directory).
$StartPath = Get-Location
# Delete .vs, bin, and obj directories.
Remove-SpecialDirectories -RootPath $StartPath -DirName ".vs"
Remove-SpecialDirectories -RootPath $StartPath -DirName "bin"
Remove-SpecialDirectories -RootPath $StartPath -DirName "obj"