Created
January 13, 2016 11:16
-
-
Save pietergheysens/49547c2e2717f4edb2e8 to your computer and use it in GitHub Desktop.
Destroy deleted branches in TFS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Write-Host "*** Find deleted branches in TFS and destroy if not used in last 100 days ***" -ForegroundColor Yellow | |
Add-PSSnapin Microsoft.TeamFoundation.PowerShell | |
$tfsServer = Get-TfsServer -name http://<tfsserver>:8080/tfs/<tpccollection> | |
$destroyList = get-tfschilditem -item <versioncontrolpath> -server $tfsServer -Deleted | Where {$_.DeletionId -ne 0 -and $_.CheckinDate -lt (Get-Date).AddDays(-100)} | |
$deletedBranchesFound = $destroyList.Count | |
Write-Verbose "Found $deletedBranchesFound deleted branches for starting the destroy command ..." -Verbose | |
foreach($item in $destroyList) | |
{ | |
Write-Verbose $item.ServerItem -Verbose | |
tf destroy $item.ServerItem /noprompt /startcleanup | |
Write-Verbose ">> deleted branch destroyed" -Verbose | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment