Functions/Get-IATaskSchedule.ps1

Function Get-IATaskSchedule {
    <#
        .SYNOPSIS
            Returns Task Schedules.
        .DESCRIPTION
            This function is used to get Task Schedules. TaskSchedules are attached to DataDefinitions and are used to define different time related aspects of the widget like 'maximum runtime' and 'refresh interval', and many more.
        .EXAMPLE
            Get-IATaskSchedule -All
             
    #>

    Param(
        [Parameter(Mandatory = $true, ParameterSetName='Name')]
        [String] $Name,
        [Parameter(Mandatory = $true, ParameterSetName='Filter')]
        [String] $Filter,
        [Parameter(ParameterSetName='All')]
        [Switch] $All,
        [Parameter(Mandatory = $true, ParameterSetName='Id')]
        [String] $Id
    )

    $Uri = "TaskSchedules"

    if($Id){

        $Uri += "($Id)"
    }

    if($All){}
    elseif($Name){
        $Uri += "?`$filter=Title eq '$Name'"
    }
    elseif ($Filter) {
        $Uri += "?&`$filter=$Filter"
    }

    $response = Invoke-IAQuery -QueryUrl $Uri -Method Get

    if ($null -eq $response.value) {
        if($Id){

            return $response
        }
        else{

            return $null
        }
    }

    return $response.value
}