powershelladobe-reader

Script to download latest Adobe Reader DC Update


I wrote a script download the latest version of Adobe MUI DC but I am not really happy with the parsing. The script starts at https://supportdownloads.adobe.com/new.jsp, followed by some parsing, getting a link to a new site, parsing and finally getting the final download link.

I am not really sure if this is the best way of doing it?

$webclient = New-Object System.Net.WebClient

$download_folder = 'E:\Adobe_Acrobat_Reader_DC_MUI\'
$url = 'https://supportdownloads.adobe.com/support/downloads/'

    Write-Host "Downloading ...AdobeDC Update"
    try {
        If(!(Test-Path $download_folder)){
            New-Item -ItemType Directory -Force -Path "$download_folder"
        }

        $download_url = $url + ((Invoke-WebRequest $url'new.jsp').Links | where outertext -like '*MUI*Continuous*' | select href).href
        Write-Host $download_url

        $download_url = $url + ((Invoke-WebRequest $download_url).Links | where outertext -like '*proceed to download*' | select outertext, href).href.replace("amp;","")
        Write-Host $download_url

        $download_url = ((Invoke-WebRequest $download_url).Links | where outertext -like '*download now*' | select outertext, href).href 
        Write-Host $download_url

        if(!(Test-Path ($download_folder + $download_url.Split('/')[-1]))){
            $webclient.DownloadFile($download_url, $download_folder + $download_url.Split('/')[-1])
        }
    } catch {
        Throw($_.Exception)
    }

Solution

  • Adobe have an Enterprise Administration Guide that is intended for businesses deploying software to multiple machines (rather than the end user themselves updating their own computer).

    For Acrobat DC there is a section for Enterprise installers:

    Adobe provides enterprise IT with a download site that contains all available installers. Most admins download the product, updates, and patches from ftp://ftp.adobe.com/pub/adobe/reader/ (or Acrobat).

    That FTP link is a much easier way to get the latest version than scraping multiple websites.

    You would just need to open the ftp site ftp://ftp.adobe.com/pub/adobe/reader/win/AcrobatDC/, get the directory listing, pick the latest folder, and then download the *MUI installer.

    So currently you would be downloading:

    ftp://ftp.adobe.com/pub/adobe/reader/win/AcrobatDC/1801120036/AcroRdrDCUpd1801120036_MUI.msp

    This technique can be used for pretty much any Adobe product as they are all available: ftp://ftp.adobe.com/pub/adobe/


    Out of curiosity on this I wrote a basic script to get the latest file from the ftp site:

    $DownloadFolder = "E:\Adobe_Acrobat_Reader_DC_MUI\"
    $FTPFolderUrl = "ftp://ftp.adobe.com/pub/adobe/reader/win/AcrobatDC/"
    
    #connect to ftp, and get directory listing
    $FTPRequest = [System.Net.FtpWebRequest]::Create("$FTPFolderUrl") 
    $FTPRequest.Method = [System.Net.WebRequestMethods+Ftp]::ListDirectory
    $FTPResponse = $FTPRequest.GetResponse()
    $ResponseStream = $FTPResponse.GetResponseStream()
    $FTPReader = New-Object System.IO.Streamreader -ArgumentList $ResponseStream
    $DirList = $FTPReader.ReadToEnd()
    
    #from Directory Listing get last entry in list, but skip one to avoid the 'misc' dir
    $LatestUpdate = $DirList -split '[\r\n]' | Where {$_} | Select -Last 1 -Skip 1
    
    #build file name
    $LatestFile = "AcroRdrDCUpd" + $LatestUpdate + "_MUI.msp"
    
    #build download url for latest file
    $DownloadURL = "$FTPFolderUrl$LatestUpdate/$LatestFile"
    
    #download file
    (New-Object System.Net.WebClient).DownloadFile($DownloadURL, "$DownloadFolder$LatestFile")