Public/Get-IdoItObjectTypeGroup.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
Function Get-IdoItObjectTypeGroup {
<#
    .SYNOPSIS
    Get-IdoItObjectTypeGroup

    .DESCRIPTION
    Calling this Cmdlet you retreive all the available object type groups configured in idoit

    .PARAMETER Limit
    Limits the number of Items the function returns.

    .PARAMETER Sort
    ** THIS SHOULD BE REMOVED - WE CAN USE Sort-Object **

    .PARAMETER OrderBy
    Can be Id, Title, Status or Constant and defines the Order in wich the result is comfing from the SQL Query

    ** THIS SHOULD BE REMOVED - WE CAN USE Sort-Object **

    .EXAMPLE
    PS> Get-IdoItObjectTypeGroup

    This will get all Type Groups

    .NOTES
    Version
    0.1.0 29.12.2017 CB initial release
#>

    Param (
        [Parameter( Mandatory = $False )]
        [int]$Limit,

        [Parameter( Mandatory = $False )]
        [ValidateSet("Asc","Desc")]
        [String]$Sort,

        [Parameter( Mandatory = $False )]
        [ValidateSet( "Id","Title","Status","Constant" )]
        [String]$OrderBy
    )

    $Params = @{}

    If ($PSBoundParameters.ContainsKey("Sort")) {
        $Params.Add("sort", $Sort.ToLower())
    }

    If ($PSBoundParameters.ContainsKey("OrderBy")) {
        $Params.Add("order_by", $OrderBy.ToLower())
    }

    If ($PSBoundParameters.ContainsKey("Limit")) {
        $Params.Add("limit", $Limit)
    }

    $ResultObj = Invoke-IdoIt -Method "cmdb.object_type_groups.read" -Params $Params

    $ResultObj = $ResultObj | Add-ObjectTypeName -TypeName 'Idoit.ObjectTypeGroup'
    Return $ResultObj
}