2016-07-27 7 views
1

Powershell을 사용하여 일부 프로세스를 자동화하려고합니다. 그 중 하나는 분기 할 때마다 사용자 스토리를 검색하는 TFS 사이트의 "Current Release"쿼리를 수동으로 우회해야하므로 검색 매개 변수에 올바른 릴리스 버전이 있습니다. 아래 스크린 샷 예. 내가 쿼리에 액세스 할 수 TFS에 가서 다음을 편집하는 경우Powershell을 사용하여 TFS (웹 사이트)에서 검색어를 편집하는 방법은 무엇입니까?

enter image description here

이다. 아래는 편집 화면입니다. 거기에있는 날짜 필드를 새 릴리스 버전의 날짜로 대체합니다. 필자가 원하는 것은 powershell을 통해 이러한 필드에 액세스하는 것입니다 (일종의 TFS 개체라고 생각합니다). 내가 서버 $server = New-Object Microsoft.TeamFoundation.Client.TeamFoundationServer($tfsURI)를 얻을 때

enter image description here

나는 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을 호출 할 수 있습니다.