Detect Adobe Reader version and skip or not install once detected.

Topics: Archive - Deployment Scripts
Jul 31, 2014 at 7:42 PM
Need help for a newbie. Set to detect Adobe Reader via GUID and version and wanted to skip if detected but it still continues to install. See script below. What I would like to happen is to detect Adobe specific version and once detected is to skip or not install since it is already installed. If it is detected that it has an older version, then continue with the install. Goal is just to replace the msp file everytime there is an update so GUID will still the same. Thanks.

<#
.SYNOPSIS
This script performs the installation or uninstallation of an application(s).  
.DESCRIPTION
The script is provided as a template to perform an install or uninstall of an application(s). 
The script either performs an "Install" deployment type or an "Uninstall" deployment type.
The install deployment type is broken down in to 3 main sections/phases: Pre-Install, Install, and Post-Install.
The script dot-sources the AppDeployToolkitMain.ps1 script which contains the logic and functions required to install or uninstall an application.
To access the help section,
.EXAMPLE
Deploy-Application.ps1
.EXAMPLE
Deploy-Application.ps1 -DeploymentType "Silent"
.EXAMPLE
Deploy-Application.ps1 -AllowSCCMReboot -AllowDefer
.EXAMPLE
Deploy-Application.ps1 -Uninstall 
.PARAMETER DeploymentType
The type of deployment to perform. [Default is "Install"]
.PARAMETER DeployMode
Specifies whether the installation should be run in Interactive, Silent or NonInteractive mode.
Interactive = Default mode
Silent = No dialogs
NonInteractive = Very silent, i.e. no blocking apps. Noninteractive mode is automatically set if an SCCM task sequence or session 0 is detected.
.PARAMETER AllowRebootPassThru
Allows the 3010 return code (requires restart) to be passed back to the parent process (e.g. SCCM) if detected from an installation. 
If 3010 is passed back to SCCM a reboot prompt will be triggered.
.NOTES
.LINK
Http://psappdeploytoolkit.codeplex.com
"#>
Param (
[ValidateSet("Install","Uninstall")] 
[string]$DeploymentType = "Install",     
[ValidateSet("Interactive","Silent","NonInteractive")]
[string]$DeployMode = "Interactive",
[switch]$AllowRebootPassThru = $false
)

*===============================================

* VARIABLE DECLARATION

Try {

*===============================================

*===============================================

Variables: Application

$appVendor = "Adobe"
$appName = "Reader"
$appVersion = "11.0.7"
$appArch = ""
$appLang = "EN"
$appRevision = "01"
$appScriptVersion = "1.0.0"
$appScriptDate = "01/04/2013"
$appScriptAuthor = "Carlito Castillo"

*===============================================

Variables: Script - Do not modify this section

$deployAppScriptFriendlyName = "Deploy Application"
$deployAppScriptVersion = "3.0.0"
$deployAppScriptDate = "01/04/2014"
$deployAppScriptParameters = $psBoundParameters

Variables: Environment

$scriptDirectory = Split-Path -Parent $MyInvocation.MyCommand.Definition

Dot source the App Deploy Toolkit Functions

."$scriptDirectory\AppDeployToolkit\AppDeployToolkitMain.ps1"
$InstallVersion = "11.0.07"

*===============================================

* END VARIABLE DECLARATION

*===============================================

*===============================================

* PRE-INSTALLATION

If ($deploymentType -ne "uninstall") { $installPhase = "Pre-Installation"

*===============================================

# Prompt the user to close the following applications if they are running:
Show-InstallationWelcome -CloseApps "iexplore,AcroRd32,cidaemon" -AllowDefer -DeferTimes 3
# Show Progress Message (with the default message)
Show-InstallationProgress
# Get Installed Application GUID and verify if Application is installed
if ((Get-InstalledApplication -ProductCode "{AC76BA86-7AD7-1033-7B44-AB0000000001}"| where-object{$_.version -eq $InstallVersion}) -eq $Null){
    if (Get-InstalledApplication "Adobe Reader"){
        # Remove any previous versions of Adobe Reader
        Remove-MSIApplications "Adobe Reader"
    }   
#*===============================================
#* INSTALLATION 
$installPhase = "Installation"
#*===============================================

    # Install the base MSI and apply a transform
    Execute-MSI -Action Install -Path "AcroRead.msi" -Transform "AcroRead.mst"
    # Install the patch
    Execute-MSI -Action Patch -Path "AdbeRdrUpd11007.msp" 
    }

*===============================================

* POST-INSTALLATION

$installPhase = "Post-Installation"

*===============================================

*===============================================

* ROLLBACK

} Elseif ($deploymentType -eq "uninstall") { $installPhase = "uninstall"
# Prompt the user to close the following applications if they are running:
Show-InstallationWelcome -CloseApps "iexplore,AcroRd32,cidaemon,winword,excel" -AllowDefer -DeferTimes 3
# Show Progress Message (with a message to indicate the application is being uninstalled)
Show-InstallationProgress -StatusMessage "Rolling Back Application $installTitle. Please Wait..." 
# Remove this version of Adobe Reader
Execute-MSI -Action Uninstall -Path "{AC76BA86-7AD7-1033-7B44-AB0000000001}"
# Install Previous Version of Adobe Reader
Execute-MSI -Action Install -Path "$scriptDirectory\rollback\AcroRead.msi" -Transform "AcroRead.mst"
# Install the patch
Execute-MSI -Action Patch -Path "$scriptDirectory\rollback\AdbeRdrUpd11006.msp"
}
} Catch {$exceptionMessage = "$($_.Exception.Message) ($($_.ScriptStackTrace))"; Write-Log "$exceptionMessage"; Show-DialogBox -Text $exceptionMessage -Icon "Stop"; Exit-Script -ExitCode 1} # Catch any errors in this script
Exit-Script -ExitCode 0 # Otherwise call the Exit-Script function to perform final cleanup operations

*===============================================

Coordinator
Aug 1, 2014 at 9:11 PM
Hi, have a look at my post here on checking versions of installed software:

https://psappdeploytoolkit.codeplex.com/discussions/551317
Aug 4, 2014 at 7:04 PM
That worked. Thanks so much