Forked from pietergheysens/DestroyDeletedBranchesInTFS.ps1
Created
January 21, 2016 20:50
-
-
Save bleissem/b342c261f4c2e992f7f7 to your computer and use it in GitHub Desktop.
Destroy deleted branches in TFS
This file contains hidden or 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