param([string[]]$Args) $here=Split-Path -LiteralPath $MyInvocation.MyCommand.Path -Parent $bestVer=$null; $bestPath=$null $files=Get-ChildItem -LiteralPath $here -Filter "gov_pipeline_guard_v*.ps1" -File -ErrorAction SilentlyContinue foreach($f in $files){ if($f.Name -ieq "gov_pipeline_guard_latest.ps1"){ continue } $m=[regex]::Match($f.Name,"^gov_pipeline_guard_v([0-9]+)\.([0-9]+)\.([0-9]+)\.ps1$") if($m.Success){ try{ $v=New-Object System.Version ($m.Groups[1].Value+"."+$m.Groups[2].Value+"."+$m.Groups[3].Value) } catch { continue } if($bestVer -eq $null -or $v -gt $bestVer){ $bestVer=$v; $bestPath=$f.FullName } } } if($bestPath -eq $null){ Write-Host "[BLOCK] no gov_pipeline_guard_v*.ps1 found"; exit 9 } Write-Host ("[DELEGATE] gov_pipeline_guard -> "+$bestVer.ToString()+" @ "+$bestPath) & $bestPath @Args