Public/Get-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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
Function Get-bConnectVariableDefinition() {
    <#
        .Synopsis
            Get variable definition.
        .Parameter Id
            Valid GUID of a VariableDefinition
        .Parameter Scope
            enum bConnectVariableScope.
        .Parameter Category
            Valid variable category.
        .Parameter Name
            Valid variable name.
        .Outputs
            VariableDefinition (see bConnect documentation for more details).
    #>


    Param (
        [string]$Id,
        [bConnectVariableScope]$Scope,
        [string]$Category,
        [string]$Name
    )

    $_connectVersion = Get-bConnectVersion
    If($_connectVersion -ge "1.0") {
        $_body = @{}

        If($Id) {
            $_body += @{
                Id = $Id
            }
        }

        If($Scope) {
            $_body += @{
                Scope = $Scope.ToString()
            }
        }

        If($Category) {
            $_body += @{
                Category = $Category
            }
        }

        If($Name) {
            $_body += @{
                Name = $Name
            }
        }

        return Invoke-bConnectGet -Controller "VariableDefinitions" -Version $_connectVersion -Data $_body
    } else {
        return $false
    }
}