public/Get-LeagueStandingOrder.ps1
function Get-LeagueStandingOrder { [CmdletBinding()] param( [Parameter(Mandatory=$true)] [ValidateNotNullOrEmpty()] [string]$Competition, [Parameter(Mandatory=$true)] [ValidateNotNullOrEmpty()] [Object]$Header, [Parameter(Mandatory=$true)] [ValidateNotNullOrEmpty()] [string]$Token ) process{ $ErrorActionPreference = 'Stop' try { $LeagueIdentifier = Get-LeagueIdentifier -Competition $Competition $SeasonList = Get-SeasonList -Header $Header -Token $Token | Where-Object {$_.league_id -eq $LeagueIdentifier} | Sort-Object -Property starting_at $Season = $SeasonList[-1] $TeamList = Get-TeamList -Header $Headers -Token $Token -Season $($Season.id) $LeagueStandingOrder = Get-LeagueStanding -Header $Header -Token $Token $($Season.id) $TeamObjects =@() foreach ($Team in $TeamList) { $TeamStanding = $LeagueStandingOrder | Where-Object {$_.participant_id -eq $($Team.id)} # Create prediction object $TeamObject = [PSCustomObject]@{ League = $($TeamStanding.league_id) Season = $($TeamStanding.season_id) Name = $($Season.name) Team = $($Team.name) Position = $($TeamStanding.position) Points = $($TeamStanding.points) } $TeamObjects += $TeamObject } return $TeamObjects | Sort-Object -Property Position } catch { "$($MyInvocation.MyCommand.Name): $_.Exception.Message" } # trycatch } # process } # function |