【问题标题】:export complete TFS work item incl. history with PowerShell导出完整的 TFS 工作项,包括。 PowerShell 的历史
【发布时间】:2019-04-28 06:09:58
【问题描述】:
我正在为运行 Dynamics AX 项目并使用 TFS 的客户工作。我确实可以访问 TFS 并且能够检查所有不同的工作项 - 但是,我缺少的是构建指标的概述,因为将数据导入表 (Excel) 的唯一方法不允许我获取历史记录一个工作项。
因此我想知道如何使用 PowerShell 做到这一点。我对此完全陌生,因此非常感谢您提供分步指导。
【问题讨论】:
标签:
powershell
tfs
export
history
tfs-workitem
【解决方案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