How to get a Count of the Items in my TFS Local Workspace? How to get a Count of the Items in my TFS Local Workspace? powershell powershell

How to get a Count of the Items in my TFS Local Workspace?


You can do this e.g. with TFS API:

var uri = new Uri("https://tfs.mydomain.com/tfs/myteamprojectcollection")var tpc = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(uri);var vcs = tpc.GetService<VersionControlServer>();var itemSet = vcs.GetItems("$/MyServerPath",RecursionType.Full);Console.WriteLine(itemSet.Items.Length);

You can just put it into a console app, or if you change the syntax, it can be also called as a PowerShell script.

[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.TeamFoundation.Client")[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.TeamFoundation.VersionControl.Client")$url = "https://tfs.mydomain.com/tfs/myteamprojectcollection";$tfs = [Microsoft.TeamFoundation.Client.TfsTeamProjectCollectionFactory]::GetTeamProjectCollection($url)$vcs = $tfs.GetService([Microsoft.TeamFoundation.VersionControl.Client.VersionControlServer])$set = $vcs.GetItems("$/MyServerPath", [Microsoft.TeamFoundation.VersionControl.Client.RecursionType]::Full)Write-Host $set.Items.Length