-1

I need to generate a list of the Team Project Names in a Team Project Collection.

Is there a way to do this? Maybe using Powershell?

AnotherDeveloper
  • 1,242
  • 1
  • 15
  • 36
  • 1
    Probably, yes. You'd probably have the best luck using the TFS API. Take a look at the [SDK or other .Net TFS libraries](http://stackoverflow.com/questions/24134352/where-can-i-get-tfs-sdk). – Bacon Bits Oct 04 '15 at 06:21

1 Answers1

2

Here is what I use. There are probably better ways, but this works. This is how to bind it to a drop down list. c#

        Uri myUri = new Uri("https://tfs.mytfsserver.com/tfs");

        //    Get a TfsConfigurationServer instance

        TfsConfigurationServer configServer = TfsConfigurationServerFactory.GetConfigurationServer(myUri);
        configServer.EnsureAuthenticated();
        //    Get the CatalogNode that represents the hierarchy root
        CatalogNode rootNode = configServer.CatalogNode;

        //    Get the Team Project Collections that descend from the root node
        ReadOnlyCollection<CatalogNode> teamProjectCollections = rootNode.QueryChildren(
           new Guid[] { CatalogResourceTypes.ProjectCollection },
           false,
           CatalogQueryOptions.None);

        CatalogNode teamProjectCollection = teamProjectCollections[0];

        //    Get the Team Projects that belong to the Team Project Collection
        ReadOnlyCollection<CatalogNode> teamProjects = teamProjectCollection.QueryChildren(
           new Guid[] { CatalogResourceTypes.TeamProject },
           false,
           CatalogQueryOptions.None);


        ddl_TeamProjects.DataSource = teamProjects.Select(c => c.Resource.DisplayName).ToArray();
        ddl_TeamProjects.DataBind();