Share via


Iterate over builds in VSTS

$personalAccessToken = "<your VSTS PAT Token>"

$tfsUrl= "https://myvsts.visualstudio.com/onecrm/_apis"

$headers=@{

Authorization = 'Basic ' + [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(":$($personalAccessToken)"))

}

$builds= Invoke-RestMethod -Uri $tfsUrl"/build/definitions" -Method Get -Headers $headers

foreach($build in $builds.value) {

$b = Invoke-RestMethod -Uri $build.url -Method Get -Headers $headers

$b.variables

}