Public/Search-bConnectDynamicGroup.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
Function Search-bConnectDynamicGroup() {
    <#
        .Synopsis
            Search for specified static group.
        .Parameter Term
            Searchterm for the search. Wildcards allowed.
        .Outputs
            Array of SearchResult (see bConnect documentation for more details)
    #>


    Param (
        [Parameter(Mandatory=$true)][string]$Term
    )

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

        $_groups = Invoke-bConnectGet -Controller "Search" -Version $_connectVersion -Data $_body
        $_result = @()
        Foreach($_group in $_groups) {
            If($_group.Type -eq [bConnectSearchResultType]::DynamicGroup) {
                $_result += $_group
            }
        }
        return $_result
    } else {
        return $false
    }
}