Advertisement
frithb

Epson ADK

Mar 14th, 2016
111
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.     powershell.exe -Command "& { & '.\Deploy-Application.ps1' -DeployMode 'Silent'; Exit $LastExitCode }"
  21. .EXAMPLE
  22.     powershell.exe -Command "& { & '.\Deploy-Application.ps1' -AllowRebootPassThru; Exit $LastExitCode }"
  23. .EXAMPLE
  24.     powershell.exe -Command "& { & '.\Deploy-Application.ps1' -DeploymentType 'Uninstall'; Exit $LastExitCode }"
  25. .EXAMPLE
  26.     Deploy-Application.exe -DeploymentType "Install" -DeployMode "Silent"
  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 = 'PCI'
  60.     [string]$appName = 'RCS'
  61.     [string]$appVersion = '12'
  62.     [string]$appArch = ''
  63.     [string]$appLang = 'EN'
  64.     [string]$appRevision = '04'
  65.     [string]$appScriptVersion = '1.0.0'
  66.     [string]$appScriptDate = '03/11/2016'
  67.     [string]$appScriptAuthor = 'Buster-Brian'
  68.     ##*===============================================
  69.     ## Variables: Install Titles (Only set here to override defaults set by the toolkit)
  70.     [string]$installName = ''
  71.     [string]$installTitle = ''
  72.    
  73.     ##* Do not modify section below
  74.     #region DoNotModify
  75.    
  76.     ## Variables: Exit Code
  77.     [int32]$mainExitCode = 0
  78.    
  79.     ## Variables: Script
  80.     [string]$deployAppScriptFriendlyName = 'Deploy Application'
  81.     [version]$deployAppScriptVersion = [version]'3.6.8'
  82.     [string]$deployAppScriptDate = '02/06/2016'
  83.     [hashtable]$deployAppScriptParameters = $psBoundParameters
  84.    
  85.     ## Variables: Environment
  86.     If (Test-Path -LiteralPath 'variable:HostInvocation') { $InvocationInfo = $HostInvocation } Else { $InvocationInfo = $MyInvocation }
  87.     [string]$scriptDirectory = Split-Path -Path $InvocationInfo.MyCommand.Definition -Parent
  88.    
  89.     ## Dot source the required App Deploy Toolkit Functions
  90.     Try {
  91.         [string]$moduleAppDeployToolkitMain = "$scriptDirectory\AppDeployToolkit\AppDeployToolkitMain.ps1"
  92.         If (-not (Test-Path -LiteralPath $moduleAppDeployToolkitMain -PathType 'Leaf')) { Throw "Module does not exist at the specified location [$moduleAppDeployToolkitMain]." }
  93.         If ($DisableLogging) { . $moduleAppDeployToolkitMain -DisableLogging } Else { . $moduleAppDeployToolkitMain }
  94.     }
  95.     Catch {
  96.         If ($mainExitCode -eq 0){ [int32]$mainExitCode = 60008 }
  97.         Write-Error -Message "Module [$moduleAppDeployToolkitMain] failed to load: `n$($_.Exception.Message)`n `n$($_.InvocationInfo.PositionMessage)" -ErrorAction 'Continue'
  98.         ## Exit the script, returning the exit code to SCCM
  99.         If (Test-Path -LiteralPath 'variable:HostInvocation') { $script:ExitCode = $mainExitCode; Exit } Else { Exit $mainExitCode }
  100.     }
  101.    
  102.     #endregion
  103.     ##* Do not modify section above
  104.     ##*===============================================
  105.     ##* END VARIABLE DECLARATION
  106.     ##*===============================================
  107.        
  108.     If ($deploymentType -ine 'Uninstall') {
  109.         ##*===============================================
  110.         ##* PRE-INSTALLATION
  111.         ##*===============================================
  112.         [string]$installPhase = 'Pre-Installation'
  113.        
  114.         ## 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
  115.         Show-InstallationWelcome -CheckDiskSpace -PersistPrompt
  116.        
  117.         ## Show Progress Message (with the default message)
  118.         Show-InstallationProgress
  119.        
  120.         ## <Perform Pre-Installation tasks here>
  121.         ##Create folder if not present
  122.         New-Folder -Path "$envProgramFilesX86\PCI, LLC\Chesterfield"
  123.         #Apply User modify rights to PCI folder
  124.         Execute-Process -Path "$envSystem32Directory\icacls.exe" -Parameters  "`"$envProgramFilesX86\PCI, LLC\Chesterfield`" /grant `"Users:(OI)(CI)M`"" -WindowStyle Hidden
  125.        
  126.         ##*===============================================
  127.         ##* INSTALLATION
  128.         ##*===============================================
  129.         [string]$installPhase = 'Installation'
  130.        
  131.         ## Handle Zero-Config MSI Installations
  132.         If ($useDefaultMsi) {
  133.             [hashtable]$ExecuteDefaultMSISplat =  @{ Action = 'Install'; Path = $defaultMsiFile }; If ($defaultMstFile) { $ExecuteDefaultMSISplat.Add('Transform', $defaultMstFile) }
  134.             Execute-MSI @ExecuteDefaultMSISplat; If ($defaultMspFiles) { $defaultMspFiles | ForEach-Object { Execute-MSI -Action 'Patch' -Path $_ } }
  135.         }
  136.        
  137.         ## <Perform Installation tasks here>
  138.         #Epson Slip Printer Driver
  139.         #####Execute-Process -Path "$dirFiles\Epson 6000 Driver\TMUSB64\DPInst.exe" -Parameters '/S' -WindowStyle Hidden
  140.         Execute-Process -Path "$dirFiles\Epson 6000 Driver\Setup.exe" -Parameters "-s2"
  141.  
  142.         #Epson 240E INstall
  143.         Execute-Process -Path "$dirFiles\RCS Installer\epson240e\disk1\Setup.exe" -Parameters "/a`"c:\Opos.reg`" /s" -WindowStyle Hidden
  144.         #Execute-Process -Path "$envSystem32Directory\cmd.exe" -Parameters "/c `"$dirFiles\RCS Installer\epson240e\disk1\install.bat`""
  145.        
  146.         #SU80 Canon Driver
  147.         Execute-Process -Path "$dirFiles\Su80 Driver\Driver\Setup.exe" -Parameters '/S'
  148.  
  149.         #SU80 Canon Ranger Software
  150.         Execute-Process -Path "$dirFiles\SU80 Software - Ranger\RangerForCanonCR50CR80-4.2.14.2-1.2.0.0.exe" -Parameters '/S'
  151.                                        
  152.         #RCS Install on Brodie - QA - Validation
  153.         Execute-Process -Path "$dirFiles\RCS Installer\setup.exe" -Parameters  "/s /sms /bc:\windows\temp\rcs -f2`"C:\SCCM Logs\RCS Installer.log`" -f1`"$dirFiles\RCS Installer\setup.iss`""
  154.  
  155.        
  156.         ##*===============================================
  157.         ##* POST-INSTALLATION
  158.         ##*===============================================
  159.         [string]$installPhase = 'Post-Installation'
  160.        
  161.         ## <Perform Post-Installation tasks here>
  162.        
  163.         ## Display a message at the end of the install
  164.         If (-not $useDefaultMsi) { Show-InstallationPrompt -Message 'Installation is complete.' -ButtonRightText 'OK' -Icon Information -NoWait }
  165.     }
  166.     ElseIf ($deploymentType -ieq 'Uninstall')
  167.     {
  168.         ##*===============================================
  169.         ##* PRE-UNINSTALLATION
  170.         ##*===============================================
  171.         [string]$installPhase = 'Pre-Uninstallation'
  172.        
  173.         ## Show Welcome Message, close Internet Explorer with a 60 second countdown before automatically closing
  174.         Show-InstallationWelcome -CloseApps 'iexplore' -CloseAppsCountdown 60
  175.        
  176.         ## Show Progress Message (with the default message)
  177.         Show-InstallationProgress
  178.        
  179.         ## <Perform Pre-Uninstallation tasks here>
  180.        
  181.        
  182.         ##*===============================================
  183.         ##* UNINSTALLATION
  184.         ##*===============================================
  185.         [string]$installPhase = 'Uninstallation'
  186.        
  187.         ## Handle Zero-Config MSI Uninstallations
  188.         If ($useDefaultMsi) {
  189.             [hashtable]$ExecuteDefaultMSISplat =  @{ Action = 'Uninstall'; Path = $defaultMsiFile }; If ($defaultMstFile) { $ExecuteDefaultMSISplat.Add('Transform', $defaultMstFile) }
  190.             Execute-MSI @ExecuteDefaultMSISplat
  191.         }
  192.        
  193.         # <Perform Uninstallation tasks here>
  194.        
  195.        
  196.         ##*===============================================
  197.         ##* POST-UNINSTALLATION
  198.         ##*===============================================
  199.         [string]$installPhase = 'Post-Uninstallation'
  200.        
  201.         ## <Perform Post-Uninstallation tasks here>
  202.        
  203.        
  204.     }
  205.    
  206.     ##*===============================================
  207.     ##* END SCRIPT BODY
  208.     ##*===============================================
  209.    
  210.     ## Call the Exit-Script function to perform final cleanup operations
  211.     Exit-Script -ExitCode $mainExitCode
  212. }
  213. Catch {
  214.     [int32]$mainExitCode = 60001
  215.     [string]$mainErrorMessage = "$(Resolve-Error)"
  216.     Write-Log -Message $mainErrorMessage -Severity 3 -Source $deployAppScriptFriendlyName
  217.     Show-DialogBox -Text $mainErrorMessage -Icon 'Stop'
  218.     Exit-Script -ExitCode $mainExitCode
  219. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement