AzureDevOps.VariableGroups/Public/Add-AzureDevOpsVariableGroup.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
function Add-AzureDevOpsVariableGroup
{
    <#
    .SYNOPSIS
    Create a new variable group
 
    .DESCRIPTION
    Creates a new variable group using the currently added Azure DevOps account.
 
    .PARAMETER Group
    The variable group object.
 
    .EXAMPLE
    $variables = @();
    $variables += New-AzureDevOpsVariable -Name "MyVariable" -Value "MyVariableValue";
    $variables += New-AzureDevOpsVariable -Name "MySecretVariable" -Value "MySecretVariableValue" -IsSecret $true;
    $group = New-AzureDevOpsVariableGroup -Name "MyGroup" -Description "My Awesome Group" -Variables $variables;
    Add-AzureDevOpsVariableGroup -Group $group
    #>


    param
    (
        [PSCustomObject]$Group
    )

    $body = $group | ConvertTo-Json;
    return Invoke-AzureDevOpsRestMethod -PartialUri "/distributedtask/variablegroups?api-version=4.1-preview.1" -Method Post -Body $body
}