Functions/New-IACategory.ps1

Function New-IACategory {
    <#
        .SYNOPSIS
            This is used to create a new Category. Categories can also be seen as folders.
        .DESCRIPTION
            This command will take an inputted IACategory and fit it in a webrequest after which it will be sent to Insight Analytics to be created.
        .EXAMPLE
            $IACategoryObject = New-IACategoryObject -Name 'Important Folder 1'
            $IACategory = New-IACategory -IACategory $IACategoryObject -PassThru
    #>

    Param(
        [Parameter(Mandatory = $true)]
        [PSObject] $IACategory,
        [Switch]$Passthru
    )

    $Uri = "Categories"
    $Body = $IACategory | 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
    }
}