Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save fisshy/5eaaf032dc3424fd5e794be4eb2ddd23 to your computer and use it in GitHub Desktop.
Save fisshy/5eaaf032dc3424fd5e794be4eb2ddd23 to your computer and use it in GitHub Desktop.
Lists all defined variables in shared variable groups.
Get-Content "auth.config" | foreach-object -begin {$h=@{}} -process {
$k = [regex]::split($_,'=');
if(($k[0].CompareTo("") -ne 0) -and ($k[0].StartsWith("[") -ne $True)) {
$h.Add($k[0], $k[1])
}
}
$username = $h.Get_Item("Username")
$password = $h.Get_Item("Password")
$apiVersion = "7.0"
$organization = "X"
$project = "X"
# Retrieve list of all repositories
$base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f $username,$password)))
$headers = @{
"Authorization" = ("Basic {0}" -f $base64AuthInfo)
"Accept" = "application/json"
}
$response = Invoke-RestMethod -Uri "https://dev.azure.com/$organization/$project/_apis/distributedtask/variablegroups?api-version=$apiVersion" -Headers $headers -Method Get
$variableGroups = $response.value
$variableGroups | ForEach-Object {
$variables = $_.variables
foreach($obj in $variables.PSObject.Properties) {
Write-Host $obj.Name, $obj.Value.value
}
}
[General]
Username=xx@xx.se
Password=YOUR_PERSONAL_ACCESS_TOKEN
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment