LSTANCZYK
2/21/2017 - 5:26 PM

PowerShell script to remove files generated by Visual Studio, ReSharper, etc...

PowerShell script to remove files generated by Visual Studio, ReSharper, etc...

Write-Host "Cleaning up..."

$foldersToRemove =
#	 "bin",
	 "obj",
	 "TestResults",
	 "_ReSharper.*",
    ".vs"


$filesToRemove = 
	"Thumbs.db","*.suo","*.user","*.cache"
    #`,"*.scc","*.vssscc","*.vspscc"


$old_ErrorActionPreference = $ErrorActionPreference
$ErrorActionPreference = 'SilentlyContinue'

#Remove Folders
Write-Host "Cleaning up folders" -ForegroundColor Yellow
Get-ChildItem .\ -include $foldersToRemove -force -recurse |
	where { $_.PsIsContainer } |
	foreach ($_) {
		Write-Host "  Removing folder ./$($_.FullName)"
		Remove-Item $_.FullName -force -recurse 
	}

#Remove Files
Write-Host "Cleaning up files" -ForegroundColor Yellow
Get-ChildItem .\ -include $filesToRemove -force -recurse |
	foreach ($_) {
		Write-Host "  Removing file ./$($_.FullName)"
		Remove-Item $_.FullName -force -recurse
	}
$ErrorActionPreference = $old_ErrorActionPreference 

Write-Host "Done." -ForegroundColor Green
[void][System.Console]::ReadKey($true)