Friday, July 10, 2009

Cleaning up Visual Studio TestResults with PowerShell

If you write your unit tests using Visual Studio, then you know how quickly those pesky "TestResults" folders can eat up precious disk space over time. Here is a simple, yet effective PowerShell script to seek and destroy them!

Assuming all of your code is collocated in the same parent directory, replace "C:\Projects" with your parent directory.

(get-childitem C:\Projects\* -recurse) | where{$_.name -eq "TestResults"} |% {remove-item $_.fullname -recurse}