Public/Get-JuribaTask.ps1

function Get-JuribaTask {
    <#
        .SYNOPSIS
        Returns existing Tasks.
        .DESCRIPTION
        Returns existing tasks using Dashworks API v2.
        .PARAMETER Instance
        Optional. Juriba instance to be provided if not authenticating using Connect-Juriba. For example, https://myinstance.dpc.juriba.app
        .PARAMETER APIKey
        Optional. API key to be provided if not authenticating using Connect-Juriba.
        .PARAMETER ThrottleLimit
        Optional. Maximum number of pages to request concurrently on PowerShell 7+. Defaults to 8. Set to 1 to force sequential paging.
        .PARAMETER ProjectID
        Project ID to get project tasks from
        .OUTPUTS
        Project tasks objects
        id, name, help, stage, objectType, role, showDetailsAboutLastChangeNextToTask, hideCapacitySlotsOnSelfServiceWhenOnlyOneSlot, enabled, taskType, readOnly, languages, paths
        .EXAMPLE
        PS> Get-JuribaTask -Instance "https://myinstance.dpc.juriba.app" -APIKey "xxxxx" -ProjectID 1
    #>

    [alias("Get-DwTask")]
    param(
        [Parameter(Mandatory=$false)]
        [string]$Instance,
        [Parameter(Mandatory=$false)]
        [string]$APIKey,
        [Parameter(Mandatory=$true)]
        [int]$ProjectID,
        [Parameter(Mandatory=$false)]
        [ValidateRange(1, 64)]
        [int]$ThrottleLimit = 8
    )
    if ((Get-Variable 'dwConnection' -Scope 'Global' -ErrorAction 'Ignore') -and !$APIKey -and !$Instance) {
        $APIKey = ConvertFrom-SecureString -SecureString $dwConnection.secureAPIKey -AsPlainText
        $Instance = $dwConnection.instance
    }

    if ($APIKey -and $Instance) {
        # Get tasks info
        $uri = "{0}/apiv2/Projects/{1}/tasks" -f $instance, $ProjectID
        $headers = @{
            'x-api-key' = $ApiKey
        }
        try {
            $tasks = Invoke-JuribaPagedRequest -Uri $uri -Headers $headers -ThrottleLimit $ThrottleLimit
            return $tasks
        }
        catch {
            Write-Error $_
        }
    }
    else {
        Write-Error "No connection found. Please ensure `$APIKey and `$Instance is provided or connect using Connect-Juriba before proceeding."
    }
}