Skip to content

Instantly share code, notes, and snippets.

@vadyua
Created November 7, 2015 18:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vadyua/1057a68625924edd8338 to your computer and use it in GitHub Desktop.
Save vadyua/1057a68625924edd8338 to your computer and use it in GitHub Desktop.
<# 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 = Join-Path -Path $env:USERPROFILE -ChildPath "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
@vadyua
Copy link
Author

vadyua commented Nov 7, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment