If you are stuck on upgrading to TFS 2018 due to the old deprecated XAML based builds, it can be a challenge to see how far you are from the goal of zero XAML builds.
First we need to get all projects in a collection:
$TFSProjects = (Invoke-RestMethod -Uri ($TFSServerURL + '/_apis/projects?api-version=1.0') -Method GET -UseDefaultCredentials).value | sort Name
Then we iterate through these and get alle build definitions and print out the counts for each build type.
#Get build definitions per TFS project foreach ($Project in ($TFSProjects)) { $builddefinitions = (Invoke-RestMethod -Uri ($TFSServerURL + '/' + $project.name + '/_apis/Build/definitions?api-version=2.0') -Method GET -UseDefaultCredentials).value If ($builddefinitions.count -ne 0) { Write-host $Project.name -ForegroundColor Green $builddefinitions | group type | select name, count | out-string } }
Please note that it doesn’t look at what kind of XAML build it is. It can be a compile build or deployment for Lab.
Full script:
$TFSServerURL = "HTTP://[TFSCollectionURL]" #Get projects $TFSProjects = (Invoke-RestMethod -Uri ($TFSServerURL + '/_apis/projects?api-version=1.0') -Method GET -UseDefaultCredentials).value | sort Name #Get build definitions per TFS project foreach ($Project in ($TFSProjects)) { $builddefinitions = (Invoke-RestMethod -Uri ($TFSServerURL + '/' + $project.name + '/_apis/Build/definitions?api-version=2.0') -Method GET -UseDefaultCredentials).value If ($builddefinitions.count -ne 0) { Write-host $Project.name -ForegroundColor Green $builddefinitions | group type | select name, count | out-string } }