Advertisement
AutomateMyStuff

PADT - Lego Mindstorms EV3 1.1.1

Oct 15th, 2015
232
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.codeplex.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 = 'LEGO'
  60.     [string]$appName = 'Mindstorms EV3'
  61.     [string]$appVersion = '1.1.1'
  62.     [string]$appArch = 'x86'
  63.     [string]$appLang = 'EN'
  64.     [string]$appRevision = '01'
  65.     [string]$appScriptVersion = '1.0.0'
  66.     [string]$appScriptDate = '06/18/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.1'
  79.     [string]$deployAppScriptDate = '03/26/2015'
  80.     [hashtable]$deployAppScriptParameters = $psBoundParameters
  81.    
  82.     ## Variables: Environment
  83.     [string]$scriptDirectory = Split-Path -Path $MyInvocation.MyCommand.Definition -Parent
  84.    
  85.     ## Dot source the required App Deploy Toolkit Functions
  86.     Try {
  87.         [string]$moduleAppDeployToolkitMain = "$scriptDirectory\AppDeployToolkit\AppDeployToolkitMain.ps1"
  88.         If (-not (Test-Path -Path $moduleAppDeployToolkitMain -PathType Leaf)) { Throw "Module does not exist at the specified location [$moduleAppDeployToolkitMain]." }
  89.         If ($DisableLogging) { . $moduleAppDeployToolkitMain -DisableLogging } Else { . $moduleAppDeployToolkitMain }
  90.     }
  91.     Catch {
  92.         [int32]$mainExitCode = 60008
  93.         Write-Error -Message "Module [$moduleAppDeployToolkitMain] failed to load: `n$($_.Exception.Message)`n `n$($_.InvocationInfo.PositionMessage)" -ErrorAction 'Continue'
  94.         Exit $mainExitCode
  95.     }
  96.    
  97.     #endregion
  98.     ##* Do not modify section above
  99.     ##*===============================================
  100.     ##* END VARIABLE DECLARATION
  101.     ##*===============================================
  102.        
  103.     If ($deploymentType -ine 'Uninstall') {
  104.         ##*===============================================
  105.         ##* PRE-INSTALLATION
  106.         ##*===============================================
  107.         [string]$installPhase = 'Pre-Installation'
  108.        
  109.         ## 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
  110.         Show-InstallationWelcome -CloseApps 'mindstormsev3' -AllowDefer -DeferTimes 3 -CheckDiskSpace -PersistPrompt
  111.        
  112.         ## Show Progress Message (with the default message)
  113.         Show-InstallationProgress
  114.        
  115.         ## <Perform Pre-Installation tasks here>
  116.        
  117.        
  118.         ##*===============================================
  119.         ##* INSTALLATION
  120.         ##*===============================================
  121.         [string]$installPhase = 'Installation'
  122.        
  123.         ## Handle Zero-Config MSI Installations
  124.         If ($useDefaultMsi) { Execute-MSI -Action 'Install' -Path $defaultMsiFile }
  125.        
  126.         ## <Perform Installation tasks here>
  127.         Execute-Process -Path "$dirFiles\setup.exe" -Parameters "/r:n /qn /AcceptLicenses yes"
  128.        
  129.        
  130.         ##*===============================================
  131.         ##* POST-INSTALLATION
  132.         ##*===============================================
  133.         [string]$installPhase = 'Post-Installation'
  134.        
  135.         ## <Perform Post-Installation tasks here>
  136.         Remove-File -Path "$envPublic\desktop\LEGO MINDSTORMS EV3 Home Edition.lnk"
  137.        
  138.         ## Display a message at the end of the install
  139.         If (-not $useDefaultMsi) {
  140.             If ($DeployMode -ne "Silent") {
  141.                 # Inform the user that the installation has completed
  142.                 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
  143.             }
  144.         }
  145.     }
  146.     ElseIf ($deploymentType -ieq 'Uninstall')
  147.     {
  148.         ##*===============================================
  149.         ##* PRE-UNINSTALLATION
  150.         ##*===============================================
  151.         [string]$installPhase = 'Pre-Uninstallation'
  152.        
  153.         ## Show Welcome Message, close Internet Explorer with a 60 second countdown before automatically closing
  154.         Show-InstallationWelcome -CloseApps 'mindstormsev3' -CloseAppsCountdown 60
  155.        
  156.         ## Show Progress Message (with the default message)
  157.         Show-InstallationProgress
  158.        
  159.         ## <Perform Pre-Uninstallation tasks here>
  160.        
  161.         ## Uninstall LEGO MINDSTORMS NXT x64 Driver
  162.         Execute-MSI -Action Uninstall -Path "{A0831C28-A6FA-49A3-86AE-B5AE3C9EE19C}"
  163.         ## Uninstall LEGO MINDSTORMS EV3
  164.         #Execute-MSI -Action Uninstall -Path "LEGO_SW.{5B0CB826-E499-4E6B-94F0-75B6327ED934}"
  165.         ## Uninstall LEGO MINDSTORMS EV3 Home Edition
  166.         Execute-MSI -Action Uninstall -Path "{01D821CA-B361-45E2-8748-904AFEDC1DBD}"
  167.         ## Uninstall LEGO MINDSTORMS EV3 Uninstaller
  168.         Execute-MSI -Action Uninstall -Path "{5F3092B9-4240-4037-A287-BF6F9A2996BC}"
  169.         ## Uninstall LEGO MINDSTORMS EV3 Home Content
  170.         Execute-MSI -Action Uninstall -Path "{6AAF31BC-3005-429B-90D8-1C4A18DEE73A}"
  171.         ## Uninstall LEGO MINDSTORMS EV3 Home English Support
  172.         Execute-MSI -Action Uninstall -Path "{C4CF0D3D-8724-4B20-ABB0-4C73BDEA0F63}"
  173.         ## Uninstall VI VC2008MSMs x64
  174.         Execute-MSI -Action Uninstall -Path "{07E00E94-7A78-40FA-9BEF-71C190E98041}"
  175.         ## Uninstall NI EulaDepot
  176.         Execute-MSI -Action Uninstall -Path "{87F60C46-07E2-46B4-B872-680DE4184C0A}"
  177.         ## Uninstall NI .NET Framework 4
  178.         Execute-MSI -Action Uninstall -Path "{A3A11F6C-E573-4D1C-A9D4-701D7551544B}"
  179.         ## Uninstall NI Uninstaller
  180.         Execute-MSI -Action Uninstall -Path "{C7743231-5899-418D-8CA5-22B0F654D894}"
  181.         ## Uninstall NI VC2008MSMs x86
  182.         Execute-MSI -Action Uninstall -Path "{E84997A1-4D6F-4C0B-B60D-F85B360D2666}"
  183.         ## Uninstall NI MDF Support
  184.         Execute-MSI -Action Uninstall -Path "{FA35D849-889D-4454-9532-6BE2008D2CDF}"
  185.        
  186.         ##*===============================================
  187.         ##* UNINSTALLATION
  188.         ##*===============================================
  189.         [string]$installPhase = 'Uninstallation'
  190.        
  191.         ## Handle Zero-Config MSI Uninstallations
  192.         If ($useDefaultMsi) { Execute-MSI -Action 'Uninstall' -Path $defaultMsiFile }
  193.        
  194.         # <Perform Uninstallation tasks here>
  195.        
  196.        
  197.         ##*===============================================
  198.         ##* POST-UNINSTALLATION
  199.         ##*===============================================
  200.         [string]$installPhase = 'Post-Uninstallation'
  201.        
  202.         ## <Perform Post-Uninstallation tasks here>
  203.        
  204.        
  205.     }
  206.    
  207.     ##*===============================================
  208.     ##* END SCRIPT BODY
  209.     ##*===============================================
  210.    
  211.     ## Call the Exit-Script function to perform final cleanup operations
  212.     Exit-Script -ExitCode $mainExitCode
  213. }
  214. Catch {
  215.     [int32]$mainExitCode = 60001
  216.     [string]$mainErrorMessage = "$(Resolve-Error)"
  217.     Write-Log -Message $mainErrorMessage -Severity 3 -Source $deployAppScriptFriendlyName
  218.     Show-DialogBox -Text $mainErrorMessage -Icon 'Stop'
  219.     Exit-Script -ExitCode $mainExitCode
  220. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement