Public/Get-bConnectApp.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
Function Get-bConnectApp() {
    <#
        .Synopsis
            Get specified app, all apps in given OrgUnit or all apps on an specific endpoint.
        .Parameter AppGuid
            Valid GUID of a app.
        .Parameter OrgUnitGuid
            Valid GUID of a Orgunit.
        .Parameter EndpointGuid
            Valid GUID of an endpoint.
        .Outputs
            Array of App (see bConnect documentation for more details).
    #>


    Param (
        [string]$AppGuid,
        [string]$OrgUnitGuid,
        [string]$EndpointGuid
    )

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

        If($OrgUnitGuid) {
            $_body = @{
                OrgUnit = $OrgUnitGuid
            }
        }

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

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