Created
December 21, 2016 01:03
-
-
Save johannesprinz/a61a354d3773dc99ad25bf726b396a32 to your computer and use it in GitHub Desktop.
PowerShell function to print out TFS Branch Hierarchy for all
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
[Reflection.Assembly]::Load(“Microsoft.TeamFoundation.Client, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a”); | |
[Reflection.Assembly]::Load(“Microsoft.TeamFoundation.Common, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a”); | |
[Reflection.Assembly]::Load(“Microsoft.TeamFoundation.Lab.Client, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a”); | |
[Reflection.Assembly]::Load(“Microsoft.TeamFoundation.Lab.Common, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a”); | |
[Reflection.Assembly]::Load(“Microsoft.TeamFoundation.VersionControl.Client, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a”); | |
$tfsCollectionUrl = New-Object System.URI("http://TFSServer:8080/tfs/CollectionName/"); | |
$tfsCollection = [Microsoft.TeamFoundation.Client.TfsTeamProjectCollectionFactory]::GetTeamProjectCollection($tfsCollectionUrl); | |
$versionControl = $tfsCollection.GetService([Microsoft.TeamFoundation.VersionControl.Client.VersionControlServer]); | |
function Print-Branch($depth, $branch) { | |
$indent = ""; | |
for ($tabcounter = 0; $tabcounter -lt $depth; $tabcounter++) {$indent += "`t";} | |
Write-Host $indent $branch.Properties.RootItem.Item $branch.Properties.RootItem.Version.ChangesetId | |
$childBranches = $versionControl.QueryBranchObjects($branch.Properties.RootItem, [Microsoft.TeamFoundation.VersionControl.Client.RecursionType]::OneLevel); | |
$depth++; | |
$childBranches | ?{$_.Properties.RootItem.Item -ne $branch.Properties.RootItem.Item} | %{Print-Branch -depth $depth -branch $_} | |
$childBranches = $null; | |
$depth--; | |
} | |
$rootBranches = $versionControl.QueryRootBranchObjects([Microsoft.TeamFoundation.VersionControl.Client.RecursionType]::OneLevel); | |
$rootBranches | %{Print-Branch -depth 0 -branch $_} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment