Skip to content

Instantly share code, notes, and snippets.

@vinijmoura
Created March 18, 2024 23:33
Show Gist options
  • Save vinijmoura/0d5500cc8db5d15f2ac77cf7c36ed940 to your computer and use it in GitHub Desktop.
Save vinijmoura/0d5500cc8db5d15f2ac77cf7c36ed940 to your computer and use it in GitHub Desktop.
clear
$PAT=''
$Organization=''
$Project=""
$VariableGroup=""
$AzureDevOpsAuthenicationHeader = @{Authorization = 'Basic ' + [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(":$($PAT)")) }
$UriOrganization = "https://dev.azure.com/$($Organization)/"
$uriVariableGroup = "$($UriOrganization)$($Project)/_apis/distributedtask/variablegroups?groupName=$($VariableGroup)&queryOrder=IdDescending&api-version=7.1-preview.2"
$VariableGroupResult = Invoke-RestMethod -Uri $uriVariableGroup -Method get -Headers $AzureDevOpsAuthenicationHeader
$AllVariables = ($VariableGroupResult.value[0].variables | Get-Member -MemberType NoteProperty).Name
Foreach ($vg in $AllVariables)
{
"Varible group name: $($vg)"
"Varible group value: $($VariableGroupResult.value[0].variables.$vg.value)"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment