Functions/New-IATaskSchedule.ps1

Function New-IATaskSchedule {
    <#
        .SYNOPSIS
            This is used to create a new TaskSchedule.
        .DESCRIPTION
            This command will take an inputted IATaskSchedule and fit it in a webrequest after which it will be sent to Insight Analytics to be created.
            This is mostly an internal function and is used when creating a new Widget. More detailed usage can be found in New-IAWidgetObject.
    #>

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

    $Uri = "TaskSchedules"
    $Body = $IATaskSchedule | 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
    }
}