извиняюсь за путаницу, не правильное регулярное выражение, у меня все получилось:
function Get-VersionsFromGitHub {
$url = "https://github.com/abbodi1406/vcredist/releases"
$response = Invoke-WebRequest -Uri $url
$versions = $response.Content | Select-String -Pattern "v\d+\.\d+\.\d+" -AllMatches | ForEach-Object { $_.Matches.Value }
return $versions
}
function Get-MaxVersion {
param (
[string[]]$versions
)
$maxVer = "v0.00.0"
foreach ($version in $versions) {
if ($version -match "v(\d{1,2})\.(\d{1,2})\.(\d{1,2})") {
$currentVer = "v$($matches[1]).$($matches[2]).$($matches[3])"
if ($currentVer -gt $maxVer) {
$maxVer = $currentVer
}
}
}
return $maxVer
}
$versions = Get-VersionsFromGitHub
$latestVersion = Get-MaxVersion -versions $versions
Write-Output "Max version product: $latestVersion"
Invoke-WebRequest -Uri "https://github.com/abbodi1406/vcredist/releases/download/$latestVersion/VisualCppRedist_AIO_x86_x64.exe" -OutFile ".\VisualCppRedist_AIO_x86_x64.exe"
Start-Process -FilePath ".\VisualCppRedist_AIO_x86_x64.exe" -ArgumentList "/y" -Wait
Remove-Item -Path ".\VisualCppRedist_AIO_x86_x64.exe"
pause
exit
спасибо за внимание