<# SIMPLER VERSION
$out = [Environment]::GetFolderPath("Desktop") + "\Adobe Flash Player"; $c = New-Object System.Net.WebClient; @('install_flash_player_ax.exe','install_flash_player.exe','install_flash_player_ppapi.exe') | %{ $c.DownloadFile("https://fpdownload.macromedia.com/pub/flashplayer/latest/help/$_", "$out\$_") }
#>
$out = $env:USERPROFILE+"\Downloads\Adobe Flash Player"
$client = New-Object System.Net.WebClient
$webpage = $client.DownloadString("https://www.adobe.com/products/flashplayer/distribution3.html")
$version = $webpage | Select-String -pattern 'Flash Player ([0-9\.]+) \(Win' | % { $_.Matches } | % {$_.Groups[1].Value }
if(!(Test-Path "$out\$version")) {
New-Item "$out\$version" -ItemType directory -Force | Out-Null
$urls = $webpage | Select-String -pattern '<a href="([^"]+)">Download EXE Installer</a>' -Allmatches | % { $_.Matches } | % {$_.Groups[1].Value } | Select-Object -First 2
$urls | %{
$file = Join-Path "$out\$version" ([URI]$_).Segments[-1]
$client.DownloadFile($_, $file)
}
$client.DownloadFile("https://fpdownload.macromedia.com/pub/flashplayer/latest/help/install_flash_player_ppapi.exe", "$out\$version\install_flash_player_ppapi.exe")
}
# delete old releases?
Get-ChildItem -LiteralPath $out -Force | ? { $_.PSIsContainer } | Sort-Object -Property LastWriteTime,CreationTime –Descending | Select -Skip 5 | Remove-Item -Force -Recurse