下载最新 Adob​​e Reader DC 更新的脚本

Script to download latest Adobe Reader DC Update

我写了一个脚本下载最新版本的 Adob​​e MUI DC,但我对解析不太满意。脚本从 https://supportdownloads.adobe.com/new.jsp 开始,然后进行一些解析,获取 link 到新站点,解析并最终获得最终下载 link.

我不确定这是否是最好的方法?

$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)
    }

Adobe 有一个 Enterprise Administration Guide 用于将软件部署到多台机器的企业(而不是最终用户自己更新他们自己的计算机)。

对于 Acrobat DC,有一个针对企业安装程序的部分:

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).

FTP link 比抓取多个网站更容易获得最新版本。

您只需打开 ftp 站点 ftp://ftp.adobe.com/pub/adobe/reader/win/AcrobatDC/,获取目录列表,选择最新的文件夹,然后下载 *MUI 安装程序。

所以目前您正在下载:

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

这项技术几乎可以用于任何 Adob​​e 产品,因为它们都可用:ftp://ftp.adobe.com/pub/adobe/


出于对此的好奇,我编写了一个基本脚本来从 ftp 站点获取最新文件:

$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")