-
-
Save NathanTheGr8/e8119a4ee0308389308d62bbfc86df19 to your computer and use it in GitHub Desktop.
Get-AdobeFlashMsi.ps1
This file contains hidden or 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
#Requires -Version 2 | |
function Get-AdobeFlashMsi { | |
[CmdletBinding()] | |
param ( | |
[string] | |
$Destination = $(Join-Path -Path $env:USERPROFILE -ChildPath 'Downloads' ) | |
) #param | |
begin { | |
Add-Type -AssemblyName System.Web.Extensions | |
Write-Verbose -Message "Setting TLS 1.2 as the .NET SecurityProtocol for the download." | |
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 | |
} #begin | |
process { | |
$MajorVersion = (Get-LatestFlashVersion).Major | |
$FlashActiveX = "https://www.adobe.com/etc/adc/token/generation.installerlink.json?href=https%3A%2F%2Ffpdownload.macromedia.com%2Fget%2Fflashplayer%2Fdistyfp%2Fcurrent%2Fwin%2Finstall_flash_player_$($MajorVersion)_active_x.msi" | |
$FlashPlugin = "https://www.adobe.com/etc/adc/token/generation.installerlink.json?href=https%3A%2F%2Ffpdownload.macromedia.com%2Fget%2Fflashplayer%2Fdistyfp%2Fcurrent%2Fwin%2Finstall_flash_player_$($MajorVersion)_plugin.msi" | |
$FlashPpapi = "https://www.adobe.com/etc/adc/token/generation.installerlink.json?href=https%3A%2F%2Ffpdownload.macromedia.com%2Fget%2Fflashplayer%2Fdistyfp%2Fcurrent%2Fwin%2Finstall_flash_player_$($MajorVersion)_ppapi.msi" | |
$FlashUrls = @($FlashActiveX,$FlashPlugin,$FlashPpapi) | |
$FlashUrls | ForEach-Object { | |
Write-Verbose -Message "Getting download token from Adobe" | |
$JsonResponse = (New-Object System.Net.WebClient).DownloadString($_) | |
Write-Verbose -Message "Extract the URL string from the JSON response" | |
$Url = (New-Object System.Web.Script.Serialization.JavaScriptSerializer).DeserializeObject($JsonResponse).Values | |
Write-Verbose -Message "Determining filename" | |
$FileName = $($Url.Split('?')[0].Split('/')[-1]) | |
$FilePath = Join-Path -Path $Destination -ChildPath $FileName | |
Write-Verbose -Message "Downloading $FileName" | |
(New-Object System.Net.WebClient).DownloadFile("$Url","$FilePath") | |
} #ForEach | |
} #process | |
} #function Get-AdobeFlashMsi | |
function Get-LatestFlashVersion { | |
# Modified from https://github.com/auberginehill/update-adobe-flash-player/blob/master/Update-AdobeFlashPlayer.ps1 | |
$url = "https://fpdownload.macromedia.com/pub/flashplayer/masterversion/masterversion.xml" | |
$xml_versions = New-Object XML | |
$xml_versions.Load($url) | |
# The different flash types can have different version numbers. I need to loop through | |
# all of them to get be sure | |
[version]$xml_activex_win10_current = ($xml_versions.version.release.ActiveX_win10.version).replace(",",".") | |
[version]$xml_activex_edge_current = ($xml_versions.version.release.ActiveX_Edge.version).replace(",",".") | |
[version]$xml_activex_win_current = ($xml_versions.version.release.ActiveX_win.version).replace(",",".") | |
[version]$xml_plugin_win_current = ($xml_versions.version.release.NPAPI_win.version).replace(",",".") | |
[version]$xml_ppapi_win_current = ($xml_versions.version.release.PPAPI_win.version).replace(",",".") | |
$FlashVersions = $xml_activex_win10_current,$xml_activex_edge_current,$xml_activex_win_current,$xml_plugin_win_current,$xml_ppapi_win_current | |
$FlashVersions = Sort-Object -InputObject $FlashVersions -Descending | |
$LatestAppVersion = $FlashVersions[0] | |
return $LatestAppVersion | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment