public/Get-FootballFixtureList.ps1
function Get-FootballFixtureList { [CmdletBinding()] param( [Parameter(Mandatory=$true)] [ValidateNotNullOrEmpty()] [string]$Competition, [Parameter(Mandatory=$true)] [ValidateNotNullOrEmpty()] [string]$YearMonth, [Parameter(Mandatory=$true)] [ValidateNotNullOrEmpty()] [string]$Path ) process{ $ErrorActionPreference = 'Stop' # C:\Users\colin\Desktop\sportsmonk\sportsmonk-predictions\eng-premier $CompetitionPredictionFolder = "$Path\sportsmonk-predictions\$Competition" $CompetitionPredictionFolderExists = Test-Path -Path $CompetitionPredictionFolder if ($CompetitionPredictionFolderExists) { $CompetitionPredictionFolder = Get-ChildItem $CompetitionPredictionFolder # C:\Users\colin\Desktop\sportsmonk\sportsmonk-predictions\eng-premier\2025-02-01 # C:\Users\colin\Desktop\sportsmonk\sportsmonk-predictions\eng-premier\2025-02-02 $CompetitionPredictionDateFolder = $CompetitionPredictionFolder | Get-ChildItem | Where-Object {$_.FullName -like "*$YearMonth*"} # C:\Users\colin\Desktop\sportsmonk\sportsmonk-predictions\eng-premier\2025-02-02\eng-premier-240-2025-02-02.csv $CompetitionPredictionDateFiles = $CompetitionPredictionDateFolder | Get-ChildItem -File | Where-Object {$_.FullName -like '*240*'} [PSCustomObject]$Objects =@() foreach ($CompetitionPredictionDateFile in $CompetitionPredictionDateFiles) { $FixturesToPlay = Import-Csv -Path $($CompetitionPredictionDateFile.FullName) $Object = [PSCustomObject]@{ Competition = $Competition FixturesToPlay = $($FixturesToPlay.Count) Path = $($CompetitionPredictionDateFile.FullName).Split('\sportsmonk-predictions\')[1] } $Objects += $Object } # foreach $Objects } # if } # process } # function |