Visual studio 使用Powershell从TFS获取团队项目名称

Visual studio 使用Powershell从TFS获取团队项目名称,visual-studio,powershell,tfs,Visual Studio,Powershell,Tfs,我需要在团队项目集合中生成团队项目名称的列表 有办法做到这一点吗?可能使用Powershell?以下是我使用的。也许有更好的方法,但这是可行的。这是如何将其绑定到下拉列表。c# urimyuri=新的Uri(“https://tfs.mytfsserver.com/tfs"); //获取TfsConfigurationServer实例 TfsConfigurationServer configServer=TfsConfigurationServerFactory.GetConfiguratio

我需要在团队项目集合中生成团队项目名称的列表


有办法做到这一点吗?可能使用Powershell?

以下是我使用的。也许有更好的方法,但这是可行的。这是如何将其绑定到下拉列表。c#

urimyuri=新的Uri(“https://tfs.mytfsserver.com/tfs");
//获取TfsConfigurationServer实例
TfsConfigurationServer configServer=TfsConfigurationServerFactory.GetConfigurationServer(myUri);
configServer.EnsureAuthenticated();
//获取表示层次结构根的CatalogNode
CatalogNode根节点=configServer.CatalogNode;
//获取从根节点派生的团队项目集合
ReadOnlyCollection teamProjectCollections=rootNode.QueryChildren(
新Guid[]{CatalogResourceTypes.ProjectCollection},
假,,
目录查询选项。无);
CatalogNode teamProjectCollection=teamProjectCollections[0];
//获取属于团队项目集合的团队项目
ReadOnlyCollection teamProjects=teamProjectCollection.QueryChildren(
新Guid[]{CatalogResourceTypes.TeamProject},
假,,
目录查询选项。无);
ddl_TeamProjects.DataSource=TeamProjects.Select(c=>c.Resource.DisplayName).ToArray();
ddl_TeamProjects.DataBind();

可能是的。使用TFSAPI您可能会有最好的运气。请看下面的图片。
        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();