2016-07-27 13 views
1

私はPowershellでいくつかのプロセスを自動化しようとしています。そのうちの1つは、分岐を行うたびに、ユーザーストーリーを検索するTFSサイトの "Current Release"クエリを手作業で掘り下げなければならないため、検索パラメータに適切なリリースバージョンが含まれています。以下のスクリーンショットの例。PowershellでTFS(ウェブサイト)のクエリを編集するには?

enter image description here

私は、クエリにアクセスし、それを編集するTFSに行くところです。以下はエディタ画面です。そこにある日付フィールドを新しいリリースバージョンの日付に置き換えます。私が望むのは、powershellを使ってこれらのフィールドにアクセスすることです(何らかのTFSオブジェクトとして考えると思います)。

enter image description here

私は、サーバー$server = New-Object Microsoft.TeamFoundation.Client.TeamFoundationServer($tfsURI)を得るとき、私はPowerShell用TFSのパワーツールをいじり、だけでなく、オブジェクトのもののいくつかしてきました。しかし、google-fuを使用して、それをちょうど混乱させると、私はPowershellからクエリを編集する方法を理解できません。誰も助けることができますか?

答えて

0

これはあなたの質問に対する直接的な回答ではありませんが、以下はおそらくあなた自身でそれを理解し始めるのに十分です。私はあなたがおそらくこの機能を達成することはできません$version_control_server

## 
# http://blog.majcica.com/2015/11/15/powershell-tips-and-tricks-retrieving-tfs-collections-and-projects/ 
# this will get you a list of tfs projects hosted on a tfs server 
## 

# Add-Type -AssemblyName "Microsoft.TeamFoundation.Client, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" 
Add-Type -Path 'C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\Microsoft.TeamFoundation.Client.dll' 

$uri = 'http://host:8080/tfs' 

$tfsConfigurationServer = [Microsoft.TeamFoundation.Client.TfsConfigurationServerFactory]::GetConfigurationServer($uri) 
$tpcService = $tfsConfigurationServer.GetService('Microsoft.TeamFoundation.Framework.Client.ITeamProjectCollectionService') 

$sortedCollections = $tpcService.GetCollections() | Sort-Object -Property Name 

# 

$collection = $sortedCollections[0] 

$collectionUri = $uri + '/' + $collection.Name 
$tfsTeamProject = [Microsoft.TeamFoundation.Client.TfsTeamProjectCollectionFactory]::GetTeamProjectCollection($collectionUri) 
$cssService = $tfsTeamProject.GetService('Microsoft.TeamFoundation.Server.ICommonStructureService3') 
$sortedProjects = $cssService.ListProjects() | Sort-Object -Property Name 


## 
# https://lajak.wordpress.com/2013/01/28/tfs-2012-api-find-all-solutions-in-source-control/ 
# this will take your list of projects and get list of solution paths within those projects 
## 


Add-Type -Path 'C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\Microsoft.TeamFoundation.VersionControl.Client.dll' 

$version_control_server = $tfsTeamProject.GetService('Microsoft.TeamFoundation.VersionControl.Client.VersionControlServer') 

$solution_items = $version_control_server.getitems(
    '$/*', 
    [Microsoft.TeamFoundation.VersionControl.Client.VersionSpec]::Latest, 
    [Microsoft.TeamFoundation.VersionControl.Client.RecursionType]::Full, 
    [Microsoft.TeamFoundation.VersionControl.Client.DeletedState]::NonDeleted, 
    [Microsoft.TeamFoundation.VersionControl.Client.ItemType]::File 
) 

$path_array = $solution_items.items | foreach-object { $_.serveritem } 

($path_array -join "`r`n") | out-file 'C:\tfs_paths.txt' 

## 
0

TFSパワーツールを使用することになると思います。 this articleに記載されているような.NETクライアントライブラリを使用するか、VSTS Rest APIを呼び出してUpdate a queryを呼び出します。

関連する問題