Advertisement
AutomateMyStuff

PADT - ExamView Assessment Suite 8.1.107.70421

Oct 19th, 2015
867
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <#
  2. .SYNOPSIS
  3.     This script performs the installation or uninstallation of an application(s).
  4. .DESCRIPTION
  5.     The script is provided as a template to perform an install or uninstall of an application(s).
  6.     The script either performs an "Install" deployment type or an "Uninstall" deployment type.
  7.     The install deployment type is broken down into 3 main sections/phases: Pre-Install, Install, and Post-Install.
  8.     The script dot-sources the AppDeployToolkitMain.ps1 script which contains the logic and functions required to install or uninstall an application.
  9. .PARAMETER DeploymentType
  10.     The type of deployment to perform. Default is: Install.
  11. .PARAMETER DeployMode
  12.     Specifies whether the installation should be run in Interactive, Silent, or NonInteractive mode. Default is: Interactive. Options: Interactive = Shows dialogs, Silent = No dialogs, NonInteractive = Very silent, i.e. no blocking apps. NonInteractive mode is automatically set if it is detected that the process is not user interactive.
  13. .PARAMETER AllowRebootPassThru
  14.     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.
  15. .PARAMETER TerminalServerMode
  16.     Changes to "user install mode" and back to "user execute mode" for installing/uninstalling applications for Remote Destkop Session Hosts/Citrix servers.
  17. .PARAMETER DisableLogging
  18.     Disables logging to file for the script. Default is: $false.
  19. .EXAMPLE
  20.     Deploy-Application.ps1
  21. .EXAMPLE
  22.     Deploy-Application.ps1 -DeployMode 'Silent'
  23. .EXAMPLE
  24.     Deploy-Application.ps1 -AllowRebootPassThru -AllowDefer
  25. .EXAMPLE
  26.     Deploy-Application.ps1 -DeploymentType Uninstall
  27. .NOTES
  28.     Toolkit Exit Code Ranges:
  29.     60000 - 68999: Reserved for built-in exit codes in Deploy-Application.ps1, Deploy-Application.exe, and AppDeployToolkitMain.ps1
  30.     69000 - 69999: Recommended for user customized exit codes in Deploy-Application.ps1
  31.     70000 - 79999: Recommended for user customized exit codes in AppDeployToolkitExtensions.ps1
  32. .LINK
  33.     http://psappdeploytoolkit.com
  34. #>
  35. [CmdletBinding()]
  36. Param (
  37.     [Parameter(Mandatory=$false)]
  38.     [ValidateSet('Install','Uninstall')]
  39.     [string]$DeploymentType = 'Install',
  40.     [Parameter(Mandatory=$false)]
  41.     [ValidateSet('Interactive','Silent','NonInteractive')]
  42.     [string]$DeployMode = 'Interactive',
  43.     [Parameter(Mandatory=$false)]
  44.     [switch]$AllowRebootPassThru = $false,
  45.     [Parameter(Mandatory=$false)]
  46.     [switch]$TerminalServerMode = $false,
  47.     [Parameter(Mandatory=$false)]
  48.     [switch]$DisableLogging = $false
  49. )
  50.  
  51. Try {
  52.     ## Set the script execution policy for this process
  53.     Try { Set-ExecutionPolicy -ExecutionPolicy 'ByPass' -Scope 'Process' -Force -ErrorAction 'Stop' } Catch {}
  54.    
  55.     ##*===============================================
  56.     ##* VARIABLE DECLARATION
  57.     ##*===============================================
  58.     ## Variables: Application
  59.     [string]$appVendor = 'eInstruction'
  60.     [string]$appName = 'ExamView Assessment Suite'
  61.     [string]$appVersion = '8.1.107.70421'
  62.     [string]$appArch = 'x86'
  63.     [string]$appLang = 'EN'
  64.     [string]$appRevision = '01'
  65.     [string]$appScriptVersion = '1.0.0'
  66.     [string]$appScriptDate = '09/02/2015'
  67.     [string]$appScriptAuthor = 'Chris Thomas'
  68.     ##*===============================================
  69.    
  70.     ##* Do not modify section below
  71.     #region DoNotModify
  72.    
  73.     ## Variables: Exit Code
  74.     [int32]$mainExitCode = 0
  75.    
  76.     ## Variables: Script
  77.     [string]$deployAppScriptFriendlyName = 'Deploy Application'
  78.     [version]$deployAppScriptVersion = [version]'3.6.5'
  79.     [string]$deployAppScriptDate = '08/17/2015'
  80.     [hashtable]$deployAppScriptParameters = $psBoundParameters
  81.    
  82.     ## Variables: Environment
  83.     If (Test-Path -LiteralPath 'variable:HostInvocation') { $InvocationInfo = $HostInvocation } Else { $InvocationInfo = $MyInvocation }
  84.     [string]$scriptDirectory = Split-Path -Path $InvocationInfo.MyCommand.Definition -Parent
  85.    
  86.     ## Dot source the required App Deploy Toolkit Functions
  87.     Try {
  88.         [string]$moduleAppDeployToolkitMain = "$scriptDirectory\AppDeployToolkit\AppDeployToolkitMain.ps1"
  89.         If (-not (Test-Path -LiteralPath $moduleAppDeployToolkitMain -PathType 'Leaf')) { Throw "Module does not exist at the specified location [$moduleAppDeployToolkitMain]." }
  90.         If ($DisableLogging) { . $moduleAppDeployToolkitMain -DisableLogging } Else { . $moduleAppDeployToolkitMain }
  91.     }
  92.     Catch {
  93.         If ($mainExitCode -eq 0){ [int32]$mainExitCode = 60008 }
  94.         Write-Error -Message "Module [$moduleAppDeployToolkitMain] failed to load: `n$($_.Exception.Message)`n `n$($_.InvocationInfo.PositionMessage)" -ErrorAction 'Continue'
  95.         ## Exit the script, returning the exit code to SCCM
  96.         If (Test-Path -LiteralPath 'variable:HostInvocation') { $script:ExitCode = $mainExitCode; Exit } Else { Exit $mainExitCode }
  97.     }
  98.    
  99.     #endregion
  100.     ##* Do not modify section above
  101.     ##*===============================================
  102.     ##* END VARIABLE DECLARATION
  103.     ##*===============================================
  104.        
  105.     If ($deploymentType -ine 'Uninstall') {
  106.         ##*===============================================
  107.         ##* PRE-INSTALLATION
  108.         ##*===============================================
  109.         [string]$installPhase = 'Pre-Installation'
  110.        
  111.         ## Show Welcome Message, close Internet Explorer if required, allow up to 3 deferrals, verify there is enough disk space to complete the install, and persist the prompt
  112.         Show-InstallationWelcome -CloseApps 'evpro, evmanage, evplay' -AllowDefer -DeferTimes 3 -CheckDiskSpace -PersistPrompt
  113.        
  114.         ## Show Progress Message (with the default message)
  115.         Show-InstallationProgress
  116.        
  117.         ## <Perform Pre-Installation tasks here>
  118.        
  119.        
  120.         ##*===============================================
  121.         ##* INSTALLATION
  122.         ##*===============================================
  123.         [string]$installPhase = 'Installation'
  124.        
  125.         ## Handle Zero-Config MSI Installations
  126.         If ($useDefaultMsi) {
  127.             [hashtable]$ExecuteDefaultMSISplat =  @{ Action = 'Install'; Path = $defaultMsiFile }; If ($defaultMstFile) { $ExecuteDefaultMSISplat.Add('Transform', $defaultMstFile) }
  128.             Execute-MSI @ExecuteDefaultMSISplat; If ($defaultMspFiles) { $defaultMspFiles | ForEach-Object { Execute-MSI -Action 'Patch' -Path $_ } }
  129.         }
  130.        
  131.         ## <Perform Installation tasks here>
  132.         Execute-Process -Path "$dirFiles\ExamView_Retail_Windows_8.1.107.70421.exe" -Parameters "/S /v/qn"
  133.  
  134.        
  135.         ##*===============================================
  136.         ##* POST-INSTALLATION
  137.         ##*===============================================
  138.         [string]$installPhase = 'Post-Installation'
  139.        
  140.         ## <Perform Post-Installation tasks here>
  141.         Remove-File -Path "$envPublic\Desktop\ExamView TestPlayer.lnk"
  142.         Remove-File -Path "$envPublic\Desktop\ExamView TestManager.lnk"
  143.         Remove-File -Path "$envPublic\Desktop\ExamView TestGenerator.lnk"
  144.        
  145.         ## Display a message at the end of the install
  146.         If (-not $useDefaultMsi) {
  147.             If ($DeployMode -ne "Silent") {
  148.                 # Inform the user that the installation has completed
  149.                 Show-InstallationPrompt -Message "$installTitle has completed installation. `n `n If you encounter any issues with this software please call Help Desk at x1215." -Icon "Information" -ButtonMiddleText "OK" -NoWait
  150.             }
  151.         }
  152.     }
  153.     ElseIf ($deploymentType -ieq 'Uninstall')
  154.     {
  155.         ##*===============================================
  156.         ##* PRE-UNINSTALLATION
  157.         ##*===============================================
  158.         [string]$installPhase = 'Pre-Uninstallation'
  159.        
  160.         ## Show Welcome Message, close Internet Explorer with a 60 second countdown before automatically closing
  161.         Show-InstallationWelcome -CloseApps 'evpro, evmanage, evplay' -CloseAppsCountdown 60
  162.        
  163.         ## Show Progress Message (with the default message)
  164.         Show-InstallationProgress
  165.        
  166.         ## <Perform Pre-Uninstallation tasks here>
  167.        
  168.        
  169.         ##*===============================================
  170.         ##* UNINSTALLATION
  171.         ##*===============================================
  172.         [string]$installPhase = 'Uninstallation'
  173.        
  174.         ## Handle Zero-Config MSI Uninstallations
  175.         If ($useDefaultMsi) {
  176.             [hashtable]$ExecuteDefaultMSISplat =  @{ Action = 'Uninstall'; Path = $defaultMsiFile }; If ($defaultMstFile) { $ExecuteDefaultMSISplat.Add('Transform', $defaultMstFile) }
  177.             Execute-MSI @ExecuteDefaultMSISplat
  178.         }
  179.        
  180.         # <Perform Uninstallation tasks here>
  181.         Execute-MSI -Action Uninstall -Path "{C59DE8FB-B81E-4386-B719-A8C95C16544B}"
  182.        
  183.        
  184.         ##*===============================================
  185.         ##* POST-UNINSTALLATION
  186.         ##*===============================================
  187.         [string]$installPhase = 'Post-Uninstallation'
  188.        
  189.         ## <Perform Post-Uninstallation tasks here>
  190.        
  191.        
  192.     }
  193.    
  194.     ##*===============================================
  195.     ##* END SCRIPT BODY
  196.     ##*===============================================
  197.    
  198.     ## Call the Exit-Script function to perform final cleanup operations
  199.     Exit-Script -ExitCode $mainExitCode
  200. }
  201. Catch {
  202.     [int32]$mainExitCode = 60001
  203.     [string]$mainErrorMessage = "$(Resolve-Error)"
  204.     Write-Log -Message $mainErrorMessage -Severity 3 -Source $deployAppScriptFriendlyName
  205.     Show-DialogBox -Text $mainErrorMessage -Icon 'Stop'
  206.     Exit-Script -ExitCode $mainExitCode
  207. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement