Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <#
- .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 -DeploymentMode "Silent"
- .EXAMPLE
- Deploy-Application.ps1 -AllowRebootPassThru -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.
- .PARAMETER TerminalServerMode
- Changes to user install mode and back to user execute mode for installing/uninstalling applications on Remote Destkop Session Host/Citrix servers
- .NOTES
- .LINK
- Http://psappdeploytoolkit.codeplex.com
- "#>
- Param (
- [ValidateSet("Install","Uninstall")]
- [string] $DeploymentType = "Install",
- [ValidateSet("Interactive","Silent","NonInteractive")]
- [string] $DeployMode = "Interactive",
- [switch] $AllowRebootPassThru = $false,
- [switch] $TerminalServerMode = $false
- )
- #*===============================================
- #* VARIABLE DECLARATION
- Try {
- #*===============================================
- #*===============================================
- # Variables: Application
- $appVendor = "Sharp"
- $appName = "Panel Software/Driver"
- $appVersion = "2.8.2.13"
- $appArch = "x64"
- $appLang = "EN"
- $appRevision = "01"
- $appScriptVersion = "1.0.0"
- $appScriptDate = "07/23/2014"
- $appScriptAuthor = "Chris Thomas"
- #*===============================================
- # Variables: Script - Do not modify this section
- $deployAppScriptFriendlyName = "Deploy Application"
- $deployAppScriptVersion = [version]"3.1.4"
- $deployAppScriptDate = "06/10/2014"
- $deployAppScriptParameters = $psBoundParameters
- # Variables: Environment
- $scriptDirectory = Split-Path -Parent $MyInvocation.MyCommand.Definition
- # Dot source the App Deploy Toolkit Functions
- ."$scriptDirectory\AppDeployToolkit\AppDeployToolkitMain.ps1"
- #*===============================================
- #* END VARIABLE DECLARATION
- #*===============================================
- #*===============================================
- #* PRE-INSTALLATION
- If ($deploymentType -ne "uninstall") { $installPhase = "Pre-Installation"
- #*===============================================
- # Perform pre-installation tasks here
- # Prompt the user to close the following applications if they are running:
- Show-InstallationWelcome -CloseApps "sharppen" -AllowDefer -DeferTimes 3
- # Show Progress Message (with the default message)
- Show-InstallationProgress
- # Import SHARP certificate for driver installation
- Execute-Process -FilePath "$dirSupportFiles\certutil.exe" -Arguments "-addstore -f `"TrustedPublisher`" $dirSupportFiles\sharp.cer"
- #*===============================================
- #* INSTALLATION
- $installPhase = "Installation"
- #*===============================================
- # Perform installation tasks here
- # Install 64-bit Sharp Touch Panel Driver, Pen Software, Touch Application Pad Software and Pen Software Update
- if ((Get-WmiObject -Class Win32_OperatingSystem | Select-Object OSArchitecture) -like "*64-bit*"){
- Execute-MSI -Action Install -Path "$dirFiles\TouchPanelDriver_Setup64_ENU.msi"
- Execute-Process -FilePath "$dirFiles\PenSoftware_Setup_x64.exe" -Arguments "/s /sms /f1$dirFiles\PenSoftware_Setup_x64_Install.iss"
- Execute-MSI -Action Install -Path "$dirFiles\TouchApplicationPad_Setup_eng_x64.msi"
- Show-InstallationPrompt -Message "This next installer could not be completely automated. You will need to proceed through the prompts to complete the installation. `n`nPlease click: `n`n- Next `n- Next `n- Install `n- Finish" -PersistPrompt -Icon Exclamation -ButtonMiddleText "OK"
- Execute-Process -FilePath "$dirFiles\PenSoftware_(Ver.2.8.2.13)_Updater.exe" -Arguments "/s /sms /f1$dirFiles\PenSoftware_(Ver.2.8.2.13)_Updater_Install.iss"
- }
- #*===============================================
- #* POST-INSTALLATION
- $installPhase = "Post-Installation"
- #*===============================================
- # Perform post-installation tasks here
- # Remove desktop icons
- Remove-File -Path "$envPublic\Desktop\Overlay mode Pen Software.lnk"
- Remove-File -Path "$envPublic\Desktop\Pen Software.lnk"
- Remove-File -Path "$envPublic\Desktop\Touch Display Launcher.lnk"
- If ($DeployMode -ne "Silent") {
- # Inform the user that the installation has completed
- Show-InstallationPrompt -Message "$installTitle has completed installation. `n `n If you encounter any issues with this software please enter a ticket or call Help Desk at x4357." -Icon "Information" -ButtonMiddleText "OK" -NoWait
- }
- #*===============================================
- #* UNINSTALLATION
- } ElseIf ($deploymentType -eq "uninstall") { $installPhase = "Uninstallation"
- #*===============================================
- # Perform uninstallation tasks here
- # Prompt the user to close the following applications if they are running:
- Show-InstallationWelcome -CloseApps "sharppen" -AllowDefer -DeferTimes 3
- # Show Progress Message (with a message to indicate the application is being uninstalled)
- Show-InstallationProgress -StatusMessage "Uninstalling Application $installTitle. Please Wait..."
- # Uninstall x64 Touch Panel Driver
- Execute-MSI -Action Uninstall -Path "{7626BF3E-02BF-4896-8E71-4342BD67ED8E}"
- # Uninstall x64 Pen Software (pre-update)
- # Execute-Process -FilePath "$dirFiles\PenSoftware_Setup_x64.exe" -Arguments "/s /sms /f1$dirFiles\PenSoftware_Setup_x64_Uninstall.iss"
- # Uninstall x64 Touch Application Pad Software
- Execute-MSI -Action Uninstall -Path "{D08BFAFA-2832-41C0-A092-4D30DC626168}"
- # Uninstall x64 Pen Software Update
- Execute-MSI -Action Uninstall -Path "{0164330E-769E-4F9A-B070-9256CF175659}"
- # Uninstall x64 Pen Software with Update
- Show-InstallationPrompt -Message "This next uninstaller could not be completely automated. You will need to proceed through the prompts to complete the uninstallation. `n`nPlease click: `n`n- Remove (radio button) `n- Next `n- Yes `n- Finish" -PersistPrompt -Icon Exclamation -ButtonMiddleText "OK"
- Execute-Process -FilePath "$dirFiles\PenSoftware_(Ver.2.8.2.13)_Updater.exe" -Arguments "/s /sms /f1$dirFiles\PenSoftware_(Ver.2.8.2.13)_Updater_Uninstall.iss"
- #*===============================================
- #* END SCRIPT BODY
- } } 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
- #*===============================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement