简体   繁体   中英

Get Team Project Names from TFS using Powershell

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?

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();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM