Functions/New-IAView.ps1

Function New-IAView {
    <#
        .SYNOPSIS
            This is used to create a new View.
        .DESCRIPTION
            This command will take an inputted IAView and fit it in a webrequest after which it will be sent to Insight Analytics to be created.
        .EXAMPLE
            $IAViewObject = New-IAViewObject -IACategory $IACategory -Name 'Serious Business View' -Description 'Sample Description Here'
            $IAView = New-IAView -IAView $IAViewObject -PassThru
    #>

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

    $Uri = "Views"
    $Body = $IAView | 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
    }
}