导出完整的TFS工作项目,包括PowerShell的历史

时间:2018-11-26 14:57:07

标签: powershell tfs export history tfs-workitem

我正在为正在运行Dynamics AX项目并正在使用TFS的客户工作。我确实可以访问TFS,并且能够检查所有不同的工作项-但是,我缺少的是构建指标的概述,因为将数据存入表(Excel)的唯一方法不允许我获取历史记录工作项。

因此,我想知道如何使用PowerShell执行此操作。我对此是完全陌生的,因此,逐步的指导将受到高度赞赏。

1 个答案:

答案 0 :(得分:1)

您可以使用TFS Rest API

例如:

$serverUrl = "http://tfsServer:8080/tfs/Collection"
$workItemId = "1"

#Get the Work Item 
$workItem = Invoke-RestMethod -Uri "$($serverUrl)/_apis/wit/workitems/$($workItemId)?api-version=3.0" -UseDefaultCredentials -Method Get

#Print the revisions number
Write-Host $workItem.rev

#Get the specific revision details
$revision = Invoke-RestMethod -Uri "$($serverUrl)/_apis/wit/workitems/$($workItemId)/revisions/2?api-version=3.0" -UseDefaultCredentials -Method Get

#Print the Work Item details in the specific revision
Write-Host $revision.fields