Public/Edit-bConnectVariableDefinition.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
29
30
31
32
33
34
35
Function Edit-bConnectVariableDefinition() {
    <#
        .Synopsis
            Updates a VariableDefinition.
        .Parameter VariableDefinition
            A valid VariableDefinition with changed values
            Updating the Category or Name will change the ID of the correspondig VariableDefinition object!
        .Outputs
            VariableDefinition (see bConnect documentation for more details).
    #>


    Param (
        [Parameter(Mandatory=$true)][PSCustomObject]$VariableDefinition
    )

    $_connectVersion = Get-bConnectVersion
    If($_connectVersion -ge "1.0") {
        If(Test-Guid $VariableDefinition.Id) {
            $_body = @{
                Scope = $VariableDefinition.Scope;
                Category = $VariableDefinition.Category;
                Name = $VariableDefinition.Name;
                Type = $VariableDefinition.Type;
                Comments = $VariableDefinition.Comments
            }

            return Invoke-bConnectPatch -Controller "VariableDefinitions" -Version $_connectVersion -objectGuid $VariableDefinition.Id -Data $_body
        } else {
            return $false
        }
    } else {
        return $false
    }
}