Archive for September, 2007

Delete of Team Foundation Server Builds

Tuesday, September 11th, 2007

environment Team Foundation Server 2005

problem Delete all builds except the most 10 recent

solution Using powershell

CleanupNightlyBuild.cmd

powershell.exe c:\DirWherePs1FileIs\CleanupNightlyBuildDontCallMe.ps1

pause

CleanupNightlyBuildDontCallMe.ps1

$tfbuild="C:\\Program Files\\Microsoft Visual Studio 8\\Common7\\IDE\\TFSBuild.exe"

# sort by time
$dirs=(ls "c:\\DropLocation\\BuildLabel_*" | sort -property LastWriteTime -desc)

# delete all except the newest 10 ([math]::max)
# -f op
$dirs | select -last ([math]::Max($dirs.length-10,0)) `
| %{ .$tfbuild delete http://tfsserver:8080 TuT ('"{0}"' -f $_.Name) /noprompt }