Public/Get-bConnectEndpoint.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
Function Get-bConnectEndpoint() {
    <#
        .Synopsis
            Get specified endpoint or all endpoints in given OrgUnit
        .Parameter EndpointGuid
            Valid GUID of a endpoint
        .Parameter OrgUnitGuid
            Valid GUID of an Orgunit
        .Parameter Username
            Valid Username
        .Parameter PublicKey
            If set, the result contains the associated public keys.
        .Parameter InstalledSoftware
            If set, the result contains the installed software.
        .Parameter SnmpData
            If set, the result contains the associated snmp data.
        .Outputs
            Array of Endpoint (see bConnect documentation for more details)
    #>


    Param (
        [string]$EndpointGuid,
        [string]$OrgUnitGuid,
        [string]$DynamicGroupGuid,
        [string]$StaticGroupGuid,
        [string]$Username,
        [switch]$PublicKey,
        [switch]$InstalledSoftware,
        [switch]$SnmpData
    )

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

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

        If($DynamicGroupGuid) {
            $_body = @{
                DynamicGroup = $DynamicGroupGuid
            }
        }

        If($StaticGroupGuid) {
            $_body = @{
                StaticGroup = $StaticGroupGuid
            }
        }

        If($Username) {
            $_body = @{
                User = $Username
            }
        }

        If($PublicKey) {
            $_body += @{
                PubKey = $true
            }
        }

        If($InstalledSoftware) {
            $_body += @{
                InstalledSoftware = $true
            }
        }

        If($SnmpData) {
            $_body += @{
                SnmpData = $true
            }
        }

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