Functions/New-IAGroup.ps1

Function New-IAGroup {
    <#
        .SYNOPSIS
            This is used to create a new Group.
        .DESCRIPTION
            This command will take an inputted IAGroup and fit it in a webrequest after which it will be sent to Insight Analytics to be created.
        .EXAMPLE
            $IAGroupObject = New-IAGroupObject -IAView $IAView -Title 'Brand new group' -Description 'Flemmings favorite group'
            $IAGroup = New-IAGroup -IAGroup $IAGroupObject -PassThru
    #>

    Param(
        [Parameter(Mandatory = $true)]
        [PSObject] $IAGroup,
        [Switch] $PassThru
    )

    $Uri = "Groups"
    $Body = $IAGroup | ConvertTo-Json

    Write-Verbose "Body: $Body"

    $response = Invoke-IAQuery -QueryUrl $Uri -Method Post -Body $Body

    if($PassThru){

        if ($null -eq $response) {
            return $null
        }
        return $response
    }
}