DistributedTasks/Get-AzureDevOpsVariableGroups.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
function Get-AzureDevOpsVariableGroups {
    param (
        [string]$projectName,
        [string]$organizationUri,
        [string]$vstsToken        
    )
    Process {
        $headers  = @{ "Authorization" = "Basic $([System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes("vsts:$vstsToken")))"; }
        $uri      = "$organizationUri/$projectName/_apis/distributedtask/variablegroups?api-version=5.1-preview.1"
        
        Write-Host "Get variable groups from '$organizationUri' (project: $($projectName))" -f Gray
        return  ((Invoke-WebRequest -uri $uri -Headers $headers -UseBasicParsing).Content | ConvertFrom-Json).value
    }
}
#Set-Alias -Name Get-AzureDevOpsVariableGroups -Value Get-DevOpsVariableGroups
Export-ModuleMember -Function Get-AzureDevOpsVariableGroups #-Alias Get-DevOpsVariableGroups