Forked from pietergheysens/DestroyDeletedBranchesInTFS.ps1
Created
September 28, 2020 19:29
-
-
Save staker4/a63a1e3022207ffd57576c342a3f1273 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