public/Get-FootballFixtureResultProbability.ps1

function Get-FootballFixtureResultProbability {
    <#
        .EXAMPLE
            Get-FootballFixtureResultProbability -Competition jpn-jleague -Date 2025-03-15 -FixtureId 19348391 -Result 1-1 -Path C:\sportsmonk
     
    #>

    [CmdletBinding()]
    param(  

        [Parameter(Mandatory=$true)]
        [ValidateNotNullOrEmpty()]
        [string]$Competition,

        [Parameter(Mandatory=$true)]
        [ValidateNotNullOrEmpty()]
        [string]$Date,

        [Parameter(Mandatory=$true)]
        [ValidateNotNullOrEmpty()]
        [string]$FixtureId,

        [Parameter(Mandatory=$true)]
        [ValidateNotNullOrEmpty()]
        [string]$Path,

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

    )
    process{

        $ErrorActionPreference = 'Stop'

        try {

            $PathToUse  = "$Path\sportsmonk-predictions\$Competition\$Date\$Competition-240-$Date.csv"
            $FootballFixture = Import-Csv -Path $PathToUse | Where-Object {$_.FixtureId -eq $FixtureId}
            $FootballFixture.PSObject.Properties | ForEach-Object -Process {

                if ($($_.Name) -eq $Result) {

                    $PSObject = [PSCustomObject]@{
                        FixtureId = $($FootballFixture.FixtureId)
                        FixtureName = $($FootballFixture.FixtureName)
                        Result = $($_.Name)
                        Percentage = $($_.Value)
                    }

                    $PSObject
                
                } # if
            
            } # foreach-object

        }
        catch {

            "$($MyInvocation.MyCommand.Name): $_.Exception.Message"

        } # trycatch

    } # process

} # function