Advertisement
yralexandre

Wireshark

Mar 23rd, 2015
11
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.56 KB | None | 0 0
  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. .EXAMPLE
  18. Deploy-Application.ps1
  19. .EXAMPLE
  20. Deploy-Application.ps1 -DeployMode 'Silent'
  21. .EXAMPLE
  22. Deploy-Application.ps1 -AllowRebootPassThru -AllowDefer
  23. .EXAMPLE
  24. Deploy-Application.ps1 -DeploymentType Uninstall
  25. .NOTES
  26. .LINK
  27. http://psappdeploytoolkit.codeplex.com
  28. #>
  29. [CmdletBinding()]
  30. Param (
  31. [Parameter(Mandatory=$false)]
  32. [ValidateSet('Install','Uninstall')]
  33. [string]$DeploymentType = 'Install',
  34. [Parameter(Mandatory=$false)]
  35. [ValidateSet('Yes','No')]
  36. [String] $CheckExist = 'No',
  37. [Parameter(Mandatory=$false)]
  38. [ValidateSet('Interactive','Silent','NonInteractive')]
  39. [string]$DeployMode = 'Interactive',
  40. [Parameter(Mandatory=$false)]
  41. [switch]$AllowRebootPassThru = $false,
  42. [Parameter(Mandatory=$false)]
  43. [switch]$TerminalServerMode = $false
  44. )
  45.  
  46. Try {
  47. ## Set the script execution policy for this process
  48. Try { Set-ExecutionPolicy -ExecutionPolicy 'ByPass' -Scope 'Process' -Force -ErrorAction 'Stop' } Catch {}
  49.  
  50. ##*===============================================
  51. ##* VARIABLE DECLARATION
  52. ##*===============================================
  53. ## Variables: Application
  54. [string]$appVendor = ''
  55. [string]$appName = 'Wireshark'
  56. [string]$DisplayName = 'Wireshark'
  57. [string]$appVersion = '1.12.4'
  58. [string]$DisplayVersion = '1.12.4'
  59. [string]$appArch = ''
  60. [string]$appLang = 'EN'
  61. [string]$appRevision = '01'
  62. [string]$appScriptVersion = '1.01503.20'
  63. [string]$appScriptDate = '2015.03.20'
  64. [string]$appScriptAuthor = 'alexayr'
  65.  
  66. ##*===============================================
  67.  
  68. ##* Do not modify section below
  69. #region DoNotModify
  70.  
  71. ## Variables: Exit Code
  72. [int32]$mainExitCode = 0
  73.  
  74. ## Variables: Script
  75. [string]$deployAppScriptFriendlyName = 'Deploy Application'
  76. [version]$deployAppScriptVersion = [version]'3.6.0'
  77. [string]$deployAppScriptDate = '03/11/2015'
  78. [hashtable]$deployAppScriptParameters = $psBoundParameters
  79.  
  80. ## Variables: Environment
  81. [string]$scriptDirectory = Split-Path -Path $MyInvocation.MyCommand.Definition -Parent
  82.  
  83. ## Dot source the required App Deploy Toolkit Functions
  84. Try {
  85. [string]$moduleAppDeployToolkitMain = "$scriptDirectory\AppDeployToolkit\AppDeployToolkitMain.ps1"
  86. If (-not (Test-Path -Path $moduleAppDeployToolkitMain -PathType Leaf)) { Throw "Module does not exist at the specified location [$moduleAppDeployToolkitMain]." }
  87. . $moduleAppDeployToolkitMain
  88. }
  89. Catch {
  90. [int32]$mainExitCode = 1
  91. Write-Error -Message "Module [$moduleAppDeployToolkitMain] failed to load: `n$($_.Exception.Message)`n `n$($_.InvocationInfo.PositionMessage)" -ErrorAction 'Continue'
  92. Exit $mainExitCode
  93. }
  94.  
  95. #endregion
  96. ##* Do not modify section above
  97. ##*===============================================
  98. ##* END VARIABLE DECLARATION
  99. ##*===============================================
  100.  
  101. If ($deploymentType -ine 'Uninstall') {
  102. ##*===============================================
  103. ##* PRE-INSTALLATION
  104. ##*===============================================
  105. [string]$installPhase = 'Pre-Installation'
  106.  
  107. $InstallName = Get-InstalledApplication -Name "Wireshark"
  108. $InstallVersion = (Get-InstalledApplication -Name "Wireshark").DisplayVersion
  109. if ($CheckExist -ieq 'Yes') {Check-Exist}
  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 'wireshark,op_flse,aceanalyst' -AllowDefer -DeferTimes 5 -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. ## <Perform Installation tasks here>
  126. if ($is64Bit -eq $true) {
  127. Execute-Process -FilePath "Wireshark-win64-1.12.4.exe" -Arguments "/S /desktopicon=no /quicklaunchicon=no" -WindowStyle Hidden -IgnoreExitCodes "1,2,3"
  128. } Else {
  129. Execute-Process -FilePath "Wireshark-win32-1.12.4.exe" -Arguments "/S /desktopicon=no /quicklaunchicon=no" -WindowStyle Hidden -IgnoreExitCodes "1,2,3"
  130. }
  131.  
  132.  
  133. ##*===============================================
  134. ##* POST-INSTALLATION
  135. ##*===============================================
  136. [string]$installPhase = 'Post-Installation'
  137.  
  138. ## <Perform Post-Installation tasks here>
  139. #UpdatePrefs
  140. OverwritePrefs
  141. ## Display a message at the end of the install
  142. #Show-InstallationPrompt -Message "The installation of $DisplayName $DisplayVersion complete." -ButtonMiddleText 'OK' -Icon Information -NoWait
  143. $InstallName = Get-InstalledApplication -Name "Wireshark"
  144. $InstallVersion = (Get-InstalledApplication -Name "Wireshark").DisplayVersion
  145. StatusInstall
  146. }
  147. ElseIf ($deploymentType -ieq 'Uninstall')
  148. {
  149. ##*===============================================
  150. ##* PRE-UNINSTALLATION
  151. ##*===============================================
  152. [string]$installPhase = 'Pre-Uninstallation'
  153.  
  154. $InstallName = Get-InstalledApplication -Name "Wireshark"
  155. $InstallVersion = (Get-InstalledApplication -Name "Wireshark").DisplayVersion
  156. if ($CheckExist -ieq 'Yes') {Check-Exist}
  157. # Show Welcome Message, close Internet Explorer if required with a 60 second countdown before automatically closing
  158. Show-InstallationWelcome -CloseApps 'wireshark,op_flse,aceanalyst' -CloseAppsCountdown 60
  159.  
  160. ## Show Progress Message (with the default message)
  161. Show-InstallationProgress
  162.  
  163. ## <Perform Pre-Uninstallation tasks here>
  164.  
  165.  
  166. ##*===============================================
  167. ##* UNINSTALLATION
  168. ##*===============================================
  169. [string]$installPhase = 'Uninstallation'
  170.  
  171. # <Perform Uninstallation tasks here>
  172. if ($is64Bit -eq $true) {
  173. Execute-Process -FilePath "$envProgramFiles\Wireshark\uninstall.exe" -Arguments "/S" -WindowStyle Hidden -IgnoreExitCodes "1,2,3"
  174. } Else {
  175. Execute-Process -FilePath "$envProgramFilesX86\Wireshark\uninstall.exe" -Arguments "/S" -WindowStyle Hidden -IgnoreExitCodes "1,2,3"
  176. }
  177.  
  178. #Display a message at the end of the uninstall
  179. #Show-InstallationPrompt -Message "The uninstallation of $DisplayName $DisplayVersion complete." -ButtonMiddleText 'OK' -Icon Information -NoWait
  180. $InstallName = Get-InstalledApplication -Name "Wireshark"
  181. $InstallVersion = (Get-InstalledApplication -Name "Wireshark").DisplayVersion
  182. StatusUninstall
  183.  
  184. ##*===============================================
  185. ##* POST-UNINSTALLATION
  186. ##*===============================================
  187. [string]$installPhase = 'Post-Uninstallation'
  188.  
  189. ## <Perform Post-Uninstallation tasks here>
  190. }
  191.  
  192. ##*===============================================
  193. ##* END SCRIPT BODY
  194. ##*===============================================
  195.  
  196. ## Call the Exit-Script function to perform final cleanup operations
  197. Exit-Script -ExitCode $mainExitCode
  198. }
  199. Catch {
  200. [int32]$mainExitCode = 60001
  201. [string]$mainErrorMessage = "$(Resolve-Error)"
  202. Write-Log -Message $mainErrorMessage -Severity 3 -Source $deployAppScriptFriendlyName
  203. Show-DialogBox -Text $mainErrorMessage -Icon 'Stop'
  204. Exit-Script -ExitCode $mainExitCode
  205. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement