Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. <# SIMPLER VERSION
  2. $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\$_") }
  3. #>
  4.  
  5. $out = $env:USERPROFILE+"\Downloads\Adobe Flash Player"
  6. $client = New-Object System.Net.WebClient
  7. $webpage = $client.DownloadString("https://www.adobe.com/products/flashplayer/distribution3.html")
  8.  
  9. $version = $webpage | Select-String -pattern 'Flash Player ([0-9\.]+) \(Win' | % { $_.Matches } | % {$_.Groups[1].Value }
  10. if(!(Test-Path "$out\$version")) {
  11.     New-Item "$out\$version" -ItemType directory -Force | Out-Null
  12.     $urls = $webpage | Select-String -pattern '<a href="([^"]+)">Download EXE Installer</a>' -Allmatches | % { $_.Matches } | % {$_.Groups[1].Value } | Select-Object -First 2
  13.     $urls | %{
  14.         $file = Join-Path "$out\$version" ([URI]$_).Segments[-1]
  15.         $client.DownloadFile($_, $file)
  16.     }
  17.     $client.DownloadFile("https://fpdownload.macromedia.com/pub/flashplayer/latest/help/install_flash_player_ppapi.exe", "$out\$version\install_flash_player_ppapi.exe")
  18. }
  19. # delete old releases?
  20. Get-ChildItem -LiteralPath $out -Force | ? { $_.PSIsContainer } | Sort-Object -Property LastWriteTime,CreationTime –Descending | Select -Skip 5 | Remove-Item -Force -Recurse