Downloading and installing Adobe Reader with PowerShell

Sometimes you need to force Adobe Reader update non-interactively on a fleet of PCs. Perhaps, a zero-day vulnerability has been discovered or the auto-updater was turned off at some point. There are tons of scripts on this subject on the Internet, but very few actually work. The main reason is — most of them work by enumerating files on Adobe FTP site, then attempt to infer and download the most recent one. The problem here is that Adobe stopped updating their FTP a long time ago in the favor of a more modern CDN-based update site. There’s also some scripts that attempt to screenscrape the latest download link via regular expressions from the Adobe Reader download page. This method is quite fragile, and may change as Adobe updates the download page.

A better solution would be to use Chocolatey or WinGet packages, however if you don’t have access to these package managers, you can download and run Adobe Reader installer by parsing the JSON-response of the download form (hopefully it is less likely to change than the download page itself). Here’s how you can do it:

# determining the latest version of Reader
$session = New-Object Microsoft.PowerShell.Commands.WebRequestSession
$session.UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.67 Safari/537.36"
$result = Invoke-RestMethod -Uri `
    -WebSession $session `
    -Headers @{
        "Accept-Encoding"="gzip, deflate, br"
        "sec-ch-ua"="`" Not A;Brand`";v=`"99`", `"Chromium`";v=`"101`", `"Google Chrome`";v=`"101`""

$version = $result.products.reader[0].version
$version = $version.replace('.','')

# downloading
$URI =$Version/AcroRdrDCx64$($Version)_MUI.exe
$OutFile = Join-Path $env:TEMP "AcroRdrDCx64$($version)_MUI.exe"
Write-Host "Downloading version $version from $URI to $OutFile"
Invoke-WebRequest -Uri $URI -OutFile $OutFile -Verbose

# silent install
Start-Process -FilePath $OutFile -ArgumentList "/sAll /rs /rps /msi /norestart /quiet EULA_ACCEPT=YES" -WorkingDirectory $env:TEMP -Wait -LoadUserProfile

# cleanup
Remove-Item $OutFile

Write-Host "Normal completion"