public/Get-SeasonList.ps1

function Get-SeasonList {

    [CmdletBinding()]
    param(

        [Parameter(Mandatory=$true)]
        [ValidateNotNullOrEmpty()]
        [Object]$Header,

        [Parameter(Mandatory=$true)]
        [ValidateNotNullOrEmpty()]
        [string]$Token

    )
    process{

        $BaseUri = "https://api.sportmonks.com/v3/football/seasons"
        $AllSeasons = @()

        # Loop through all pages using the next_page link
        $count = 0
        do {

            if ($Count -lt 1) {

                $UriToUse = $BaseUri+'?api_token='+$Token

            }
            else {

                $UriToUse = $BaseUri+'&api_token='+$Token

            }

            # Fetch current page
            $Response = Invoke-RestMethod -Uri $UriToUse -Method 'GET' -Headers $Header

            # Add fixtures from the current page to the collection
            $AllSeasons += $Response.data

            # Update the BaseUri to the next page if available
            $BaseUri = $Response.pagination.next_page
            $HasMorePages = $Response.pagination.has_more
            $Count++

        } while ($HasMorePages)

        return $AllSeasons

    } # process

} # function