Last active
September 14, 2023 06:14
-
-
Save fisshy/5eaaf032dc3424fd5e794be4eb2ddd23 to your computer and use it in GitHub Desktop.
Lists all defined variables in shared variable groups.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[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