0

以下は、Visual Studio Online の特定の作業項目の以下のすべてのフィールドを提供する PowerShell スクリプトです。私の目標は、すべてのフィールドをテーブルに入れることです。これらの変数を行に書き込むことができれば、それは素晴らしいことです。または、これを行う簡単な方法があれば、共有してください:)

出力を次のようにしたいと思います。

Col1 Col2 Col3 Col4
  ID 説明 名前 日付

これは私のスクリプトです:

param(
  $vstsAccount,
  $projectName,
  $user,
  $token,
  $workitemid
)

Function QueryWorkItem{
  # Base64-encodes the Personal Access Token (PAT) appropriately
  $base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f $user,$token)))

  # Construct the REST URL to obtain Build ID
  $uri = "https://$($vstsAccount).visualstudio.com/defaultcollection/_apis/wit/workitems/$($workitemid)?api-version=1.0"

  # Invoke the REST call and capture the results (notice this uses the PATCH method)
  $result = Invoke-RestMethod -Uri $uri -ContentType "application/json" -Headers @{Authorization=("Basic {0}" -f $base64AuthInfo)} -Method Get 

  $areapath = $result.fields.'system.areapath'
  $TeamProject = $result.fields.'System.TeamProject'
  $IterationPath = $result.fields.'System.IterationPath'
  $workitemtype = $result.fields.'system.workitemtype'
  $state = $result.fields.'System.State'
  $Reason = $result.fields.'System.Reason'
  $AssignedTo = $result.fields.'System.AssignedTo'
  $CreatedDate = $result.fields.'System.CreatedDate'
  $CreatedBy = $result.fields.'System.CreatedBy'
  $Title = $result.fields.'System.Title'
  $ClosedDate = $result.fields.'Microsoft.VSTS.Common.ClosedDate'
  $ClosedBy = $result.fields.'Microsoft.VSTS.Common.ClosedBy'
  $StateChangedDate = $result.fields.'Microsoft.VSTS.Common.StateChangeDate'
  $ActivatedDate = $result.fields.'Microsoft.VSTS.Common.ActivatedDate'
  $ActivatedBy = $result.fields.'Microsoft.VSTS.Common.ActivatedBy'
  $Priority = $result.fields.'Microsoft.VSTS.Common.Priority'
  $StoryPoints = $result.fields.'Microsoft.VSTS.Scheduling.StoryPoints'
  $Risk = $result.fields.'Microsoft.VSTS.Common.Risk'
  $ValueArea = $result.fields.'Microsoft.VSTS.Common.ValueArea'
  $Tags = $result.fields.'System.Tags'

  #not proper syntax
  insert into table (all values)
}

QueryWorkItem
4

0 に答える 0