下载最新Adobe Reader DC更新的脚本

时间:2018-02-19 13:36:54

标签: powershell adobe-reader

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

我不确定这是否是最佳方式?

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

1 个答案:

答案 0 :(得分:1)

Adob​​e有一个Enterprise Administration Guide,适用于将软件部署到多台计算机的企业(而不是最终用户自己更新自己的计算机)。

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

  

Adob​​e为企业IT提供包含所有可用安装程序的下载站点。大多数管理员从ftp://ftp.adobe.com/pub/adobe/reader/(或Acrobat)下载产品,更新和补丁。

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

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

所以目前你要下载:

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

此技术可用于几乎所有Adobe产品,因为它们都可用: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")