$ProgressPreference = "SilentlyContinue"
$url = "https://informant-software.atlassian.net/wiki/spaces/Distributi/pages/151257122/Nieuwe+versies+downloaden"
$html = Invoke-WebRequest -Uri $url -UseBasicParsing
$exeMatches = [regex]::Matches($html.Content, '(\d{4}\.\d{3})\.exe', [System.Text.RegularExpressions.RegexOptions]::IgnoreCase)
$uniqueVersions = $exeMatches | ForEach-Object { $_.Groups[1].Value } | Select-Object -Unique
$latestVersion = $uniqueVersions | Sort-Object { [version]($_ -replace '(\d{4})\.(\d{3})', '$1.0.$2') } -Descending | Select-Object -First 1
$downloadUrl = "https://informant-software.atlassian.net/wiki/download/attachments/151257122/$latestVersion.exe?api=v2"
$Path = "C:\Users\sector\Downloads"
$File = "$latestVersion.exe"
if (!(Test-Path $Path)) {
New-Item -ItemType Directory -Path $Path -Force | Out-Null
}
Invoke-WebRequest -Uri $downloadUrl -OutFile "$Path\$File" -UseBasicParsing
Write-Host "Downloaded Informant version: $latestVersion" -ForegroundColor Green
if ((Test-Path "$Path\$File") -and ((Get-Item "$Path\$File").Length -gt 1KB)) {
Start-Process -FilePath "$Path\$File" -Wait
}
Start-Process explorer.exe -ArgumentList $Path\$latestVersion