Advertisement
yralexandre

AppDeployToolkitExtensions

Mar 23rd, 2015
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.20 KB | None | 0 0
  1. <#
  2. .SYNOPSIS
  3. This script is a template that allows you to extend the toolkit with your own custom functions.
  4. .DESCRIPTION
  5. The script is automatically dot-sourced by the AppDeployToolkitMain.ps1 script.
  6. .NOTES
  7. .LINK
  8. http://psappdeploytoolkit.codeplex.com
  9. #>
  10. [CmdletBinding()]
  11. Param (
  12. )
  13.  
  14. ##*===============================================
  15. ##* VARIABLE DECLARATION
  16. ##*===============================================
  17.  
  18. # Variables: Script
  19. [string]$appDeployToolkitExtName = 'PSAppDeployToolkitExt'
  20. [string]$appDeployExtScriptFriendlyName = 'App Deploy Toolkit Extensions'
  21. [version]$appDeployExtScriptVersion = [version]'1.5.0'
  22. [string]$appDeployExtScriptDate = '11/06/2014'
  23. [hashtable]$appDeployExtScriptParameters = $PSBoundParameters
  24.  
  25. ##*===============================================
  26. ##* FUNCTION LISTINGS
  27. ##*===============================================
  28.  
  29. # <Your custom functions go here>
  30. Function Check-Exist
  31. {
  32. Write-Log -Message "-CheckExist parameter was applied. Proceeding, please wait."
  33. Write-Log -Message "Attempting to determine the installation status of $DisplayName $DisplayVersion, please wait."
  34. if ($DeploymentType -ine 'Uninstall') { IsInstallStatus }
  35. elseif ($DeploymentType -ieq 'Uninstall') { IsUninstallStatus }
  36. else { Write-Log -Message "-CheckExist parameter was not applied. Proceeding, proceeding." }
  37. }
  38.  
  39. Function IsInstallStatus {
  40. if ($InstallName -and $InstallVersion) {
  41. Show-InstallationPrompt -Message "$DisplayName $DisplayVersion is installed." -ButtonMiddleText 'OK' -Icon Information -NoWait; Write-Log "ErrorCode Return value is: 1638, proceeding."; Exit-Script -ExitCode 1638
  42. } else {
  43. Write-Log -Message "$DisplayName $DisplayVersion not installed, proceeding."
  44. }
  45. }
  46.  
  47. Function IsUninstallStatus {
  48. if ($InstallName -and $InstallVersion) {
  49. Write-Log -Message "$DisplayName $DisplayVersion is installed, proceeding."
  50. } else {
  51. Show-InstallationPrompt -Message "$DisplayName $DisplayVersion not installed." -ButtonMiddleText 'OK' -Icon Information -NoWait; Write-Log "ErrorCode Return value is: 1605, proceeding."; Exit-Script -ExitCode 1605
  52. }
  53.  
  54. }
  55.  
  56. Function UpdatePrefs {
  57. $regPath = 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList'
  58. Get-ChildItem -path $regPath|
  59. ForEach-Object {
  60. $InstallPrefsDir = "AppData\Roaming\Wireshark"
  61. $StringValue = (Get-ItemProperty -path (join-path -path $regPath -child $_.pschildName) `
  62. -Name profileImagePath).profileImagePath
  63.  
  64. $DataValOld = "#gui.update.enabled: TRUE"
  65. $DataValNew = "gui.update.enabled: FALSE"
  66. $OldInstallPrefsFile = $StringValue + "\" + $InstallPrefsDir + "\preferences"
  67. #$NewnstallPrefsFile = ".\SupportFiles\preferences"
  68. $NewnstallPrefsFile = "$PWD\SupportFiles\preferences"
  69. #if ( ! (Test-Path -Path $OldInstallPrefsFile -IsValid ) ) {
  70. if ((Test-Path $OldInstallPrefsFile) -eq $true ) {
  71. (Get-Content $OldInstallPrefsFile ) | foreach-object {$_ -replace $DataValOld, $DataValNew} | Set-Content $NewnstallPrefsFile
  72. }
  73. Else {
  74. Copy-Item -Path $NewnstallPrefsFile -Destination $StringValue\$InstallPrefsDir
  75. }
  76.  
  77. }
  78. }
  79.  
  80. Function OverwritePrefs {
  81. $regPath = 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList'
  82. Get-ChildItem -path $regPath|
  83. ForEach-Object {
  84. $InstallPrefsDir = "AppData\Roaming\Wireshark"
  85. $StringValue = (Get-ItemProperty -path (join-path -path $regPath -child $_.pschildName) `
  86. -Name profileImagePath).profileImagePath
  87. $NewnstallPrefsFile = "$PWD\SupportFiles\preferences"
  88. Copy-Item -Path $NewnstallPrefsFile -Destination $StringValue\$InstallPrefsDir
  89. }
  90. }
  91.  
  92. Function StatusInstall {
  93. if ($InstallName -and $InstallVersion) {
  94. Show-InstallationPrompt -Message "The installation of $DisplayName $DisplayVersion complete." -ButtonMiddleText 'OK' -Icon Information -NoWait
  95. } else {
  96. Write-Log -Message "$DisplayName $DisplayVersion failed to install."
  97. Show-InstallationPrompt -Message "Error! The installation of $DisplayName $DisplayVersion Failed." -ButtonMiddleText 'OK' -Icon Error -NoWait
  98. }
  99. }
  100.  
  101. Function StatusUninstall {
  102. if ($InstallName -and $InstallVersion) {
  103. Write-Log -Message "$DisplayName $DisplayVersion failed to uninstall."
  104. Show-InstallationPrompt -Message "Error! The uninstallation of $DisplayName $DisplayVersion Failed." -ButtonMiddleText 'OK' -Icon Error -NoWait
  105. } else {
  106. Show-InstallationPrompt -Message "The uninstallation of $DisplayName $DisplayVersion complete." -ButtonMiddleText 'OK' -Icon Information -NoWait
  107. }
  108.  
  109. }
  110.  
  111. ##*===============================================
  112. ##* END FUNCTION LISTINGS
  113. ##*===============================================
  114.  
  115. ##*===============================================
  116. ##* SCRIPT BODY
  117. ##*===============================================
  118.  
  119. If ($scriptParentPath) {
  120. Write-Log -Message "Script [$($MyInvocation.MyCommand.Definition)] dot-source invoked by [$(((Get-Variable -Name MyInvocation).Value).ScriptName)]" -Source $appDeployToolkitExtName
  121. }
  122. Else {
  123. Write-Log -Message "Script [$($MyInvocation.MyCommand.Definition)] invoked directly" -Source $appDeployToolkitExtName
  124. }
  125.  
  126. ##*===============================================
  127. ##* END SCRIPT BODY
  128. ##*===============================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement