Packaging the latest Adobe Reader DC as an IntuneWin file

If you’re not familiar with the IntuneWin format and what it’s used for/when it’s used there’s some good background reading from Microsoft here: Prepare a Win32 app to be uploaded to Microsoft Intune | Microsoft Docs.

In short, it’s a format designed to package Windows application installers for deployment with Intune.

Kelvin has published a module that automates publishing RMM installers to Intune across all your customer tenants – you can read it here: Automating with PowerShell: uploading your RMM application to all Intune tenants – CyberDrain.

I’m planning a future blog post that integrates these steps into Kelvin’s module’s workflow providing a single script you can use to get the latest version of Adobe Reader DC and upload it to all your customers’ Intune tenants.

So here’s the script:

[CmdletBinding()]
param (
    [Parameter()]
    [ValidateSet(
        'Basque',
        'Chinese (Simplified)',
        'Chinese (Traditional)',
        'Catalan',
        'Croatian',
        'Czech',
        'Danish',
        'Dutch',
        'English',
        'English (UK)',
        'Finnish',
        'French',
        'German',
        'Hungarian',
        'Italian',
        'Japanese',
        'Korean',
        'Norwegian',
        'Polish',
        'Portuguese',
        'Romanian',
        'Russian',
        'Slovakian',
        'Slovenian',
        'Spanish',
        'Swedish',
        'Turkish',
        'Ukrainian'
    )]
    [String]$Language = 'English (UK)',
    [ValidateSet(
        'x64',
        'x86'
    )]
    [String]$Architechture = 'x64',
    [String]$InstallerSavePath,
    [String]$Win32ContentPrepToolPath,
    [String]$PackageOutputPath,
    [Switch]$CreatePackageOnly
)
if (-not ('System.Web.HTTPUtility' -as [Type])) {
    Add-Type -AssemblyName System.Web
}
$OriginalProgressPreference = $ProgressPreference
$ProgressPreference = 'SilentlyContinue'
$AdobeReleaseFeedURI = [System.URIBuilder]'https://get.adobe.com/reader/webservices/json/standalone/'

$AdobeReleaseFeedQSCollection = [System.Web.HTTPUtility]::ParseQueryString([string]::Empty)

$AdobeReleaseFeedQSCollection.Add('platform_type', 'Windows')
$AdobeReleaseFeedQSCollection.Add('platform_dist', 'Windows 10')
$AdobeReleaseFeedQSCollection.Add('platform_arch', $Architechture)
$AdobeReleaseFeedQSCollection.Add('language', $Language)

$AdobeReleaseFeedURI.Query = $AdobeReleaseFeedQSCollection.ToString()

$AdobeReleaseFeedParams = @{
    URI = $AdobeReleaseFeedURI.ToString()
    ContentType = 'application/json'
    Headers = @{
        'x-requested-with' = 'xmlhttprequest'
    }
}

$CurrentAdobeRelease = Invoke-WebRequest @AdobeReleaseFeedParams

$AdobeReleaseInfo = $CurrentAdobeRelease.Content | ConvertFrom-Json

if ($Architechture -eq 'x64') {
    $AdobeRelease = $AdobeReleaseInfo | Where-Object {
        $_.name -like '*64bit*'
    }
} else {
    $AdobeRelease = $AdobeReleaseInfo | Where-Object {
        $_.name -notlike '*64bit*'
    }
}

if ($AdobeRelease) {
    $AdobeDownloadURL = $AdobeRelease.download_url
    $AdobeReaderInstallParameters = $AdobeRelease.aih_cmd_arguments
} else {
    Throw 'Failed to retrieve Adobe Reader release information.'
}

if (Test-Path $InstallerSavePath) {
    $InstallerSavePathExists = $True
} else {
    try {
        New-Item -ItemType Directory -Path $InstallerSavePath | Out-Null
        $InstallerSavePathExists
    } catch {
        Throw 'Save path does not exist and could not be created.'
    }
}

if ($InstallerSavePathExists) {
    $AdobeReaderDownloadURL = [System.UriBuilder]$AdobeDownloadURL
    $AdobeReaderFileName = [System.IO.Path]::GetFileName($AdobeReaderDownloadURL.ToString())
    $AdobeReaderFileNameNoExt = [System.IO.Path]::GetFileNameWithoutExtension($AdobeReaderDownloadURL.ToString())
    $InstallerOutputPath = Join-Path -Path $InstallerSavePath -ChildPath $AdobeReaderFileName
    Invoke-WebRequest -Uri $AdobeReaderDownloadURL.ToString() -OutFile $InstallerOutputPath
}
if (Test-Path $Win32ContentPrepToolPath) {
    if (Test-Path $PackageOutputPath) {
        $PackageOutputPathExists = $True
    } else {
        try {
            New-Item -ItemType Directory -Path $PackageOutputPath | Out-Null
            $PackageOutputPathExists = $True
        } catch {
            Throw 'Package output path does not exist and could not be created.'
        }
    }
} else {
    Throw 'Win 32 Content Prep Tool not found. Make sure you provided the full path including the filename "IntuneWinAppUtil.exe".'
}
$PackageOutputFile = Join-Path -Path $PackageOutputPath -ChildPath "$AdobeReaderFileNameNoExt.intunewin"
if ($PackageOutputPathExists -and (-not(Test-Path $PackageOutputFile))) {
    $OriginalWorkingDirectory = $PWD
    Set-Location $InstallerSavePath
    Start-Process -FilePath $Win32ContentPrepToolPath -ArgumentList "-c $InstallerSavePath -s $AdobeReaderFileName -o $PackageOutputPath -q" -Wait -NoNewWindow
    Set-Location $OriginalWorkingDirectory
} elseif (Test-Path $PackageOutputFile) {
    Write-Host '-------------------------------------------------------------------------------'
    Write-Host 'IntuneWin package already exists for the latest release of Adobe Reader DC.'
    Write-Host "Package is located in $PackageOutputFile"
    Write-Host "To install silently with auto updates enabled use $AdobeReaderInstallParameters"
    Write-Host '-------------------------------------------------------------------------------'
}
$ProgressPreference = $OriginalProgressPreference
if (Test-Path $PackageOutputFile) {
    Write-Host '-------------------------------------------------------------------------------'
    Write-Host 'Created an IntuneWin package for the latest release of Adobe Reader DC.'
    Write-Host "Package saved to $PackageOutputFile"
    Write-Host "To install silently with auto updates enabled use $AdobeReaderInstallParameters"
    Write-Host '-------------------------------------------------------------------------------'
} else {
    Throw 'IntuneWin package not created.'
}

To invoke the script we need to satisfy it’s required parameters, an example invocation would look like this:

.\New-AdobeReaderDCInstallPackage.ps1 -Language 'English (UK)' -Architechture 'x64' -InstallerSavePath 'X:\ARDeployment\Src\' -Win32ContentPrepToolPath 'I:\Microsoft\Win32 Content Prep Tool\IntuneWinAppUtil.exe' -PackageOutputPath 'X:\ARDeployment\Output\'

Breaking down the parameters there:

  • -Language: Specify the language for the installer. For English (US) use English. A list of valid values can be found at the top of the script.
  • -Architechture: The CPU architechture for the installer – valid values are ‘x64’ and ‘x86’.
  • -InstallerSavePath: The folder to save the installer EXE into. If it doesn’t exist, the script will try to create it.
  • -Win32ContentPrepToolPath: The full path to the Microsoft Win32-Content-Prep-Tool exe file.
  • -PackageOutputPath: The folder to save the resulting intunewin file into. If it doesn’t exist, the script will try to create it.

Leave a comment