Created
November 7, 2015 18:45
-
-
Save vadyua/1057a68625924edd8338 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# 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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Distribute Updates from an Internal Server