How to: Get all process templates, work item types, and fields using REST API on Azure DevOps

Vinicius Moura
Jun 17, 2020

This script will list all processes types on Azure DevOps, theirs respective work item types and fields

Sometimes many customers ask me about Process templates, work item types, and fields and how would it be possible to list all these attributes. I believe that this script bellow is very useful to you:

An original script is available on my GitHub repository. Let’s go understand each used command.

  1. PowerShell script will receive the following parameters:
  • $PAT = Personal Access token to connect on Azure DevOps;
  • $Organization = Organization URL used on REST API;

2. Processes List = use this command to list all process templates on Azure DevOps.

UriOrganization = "https://dev.azure.com/$($Organization)/" 
$uriProcess = $UriOrganization + "_apis/work/processes/"
$processesResult = Invoke-RestMethod -Uri $uriProcess -Method get -Headers $AzureDevOpsAuthenicationHeaderForeach ($process in $processesResult.value)
{
Write-Host '=Process name:'$process.name
}

3. Work Item Types = use this command to list all work item types to each process template on Azure DevOps.

$uriWorkItemTypes = $uriProcess + "$($process.typeId)/workitemtypes/"
$workItemTypesResult = Invoke-RestMethod -Uri $uriWorkItemTypes -Method get -Headers $AzureDevOpsAuthenicationHeader
Foreach ($wit in $workItemTypesResult.value)
{
Write-Host '==Work item type:'$wit.name
}

4. Work Item Types Fields = use this command to list all fields to each work item type and process template on Azure DevOps.

$uriFields = $uriWorkItemTypes + "$($wit.referenceName)/fields"
$fieldsResult = Invoke-RestMethod -Uri $uriFields -Method get -Headers $AzureDevOpsAuthenicationHeader
Foreach ($f in $fieldsResult.value)
{
Write-Host '===Field name:'$f.name
}

After executing the script, you will have all process templates, work item types, and fields.

--

--