Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <#
- .SYNOPSIS
- This script is a template that allows you to extend the toolkit with your own custom functions.
- .DESCRIPTION
- The script is automatically dot-sourced by the AppDeployToolkitMain.ps1 script.
- .NOTES
- .LINK
- http://psappdeploytoolkit.codeplex.com
- #>
- [CmdletBinding()]
- Param (
- )
- ##*===============================================
- ##* VARIABLE DECLARATION
- ##*===============================================
- # Variables: Script
- [string]$appDeployToolkitExtName = 'PSAppDeployToolkitExt'
- [string]$appDeployExtScriptFriendlyName = 'App Deploy Toolkit Extensions'
- [version]$appDeployExtScriptVersion = [version]'1.5.0'
- [string]$appDeployExtScriptDate = '11/06/2014'
- [hashtable]$appDeployExtScriptParameters = $PSBoundParameters
- ##*===============================================
- ##* FUNCTION LISTINGS
- ##*===============================================
- # <Your custom functions go here>
- Function Check-Exist
- {
- Write-Log -Message "-CheckExist parameter was applied. Proceeding, please wait."
- Write-Log -Message "Attempting to determine the installation status of $DisplayName $DisplayVersion, please wait."
- if ($DeploymentType -ine 'Uninstall') { IsInstallStatus }
- elseif ($DeploymentType -ieq 'Uninstall') { IsUninstallStatus }
- else { Write-Log -Message "-CheckExist parameter was not applied. Proceeding, proceeding." }
- }
- Function IsInstallStatus {
- if ($InstallName -and $InstallVersion) {
- Show-InstallationPrompt -Message "$DisplayName $DisplayVersion is installed." -ButtonMiddleText 'OK' -Icon Information -NoWait; Write-Log "ErrorCode Return value is: 1638, proceeding."; Exit-Script -ExitCode 1638
- } else {
- Write-Log -Message "$DisplayName $DisplayVersion not installed, proceeding."
- }
- }
- Function IsUninstallStatus {
- if ($InstallName -and $InstallVersion) {
- Write-Log -Message "$DisplayName $DisplayVersion is installed, proceeding."
- } else {
- Show-InstallationPrompt -Message "$DisplayName $DisplayVersion not installed." -ButtonMiddleText 'OK' -Icon Information -NoWait; Write-Log "ErrorCode Return value is: 1605, proceeding."; Exit-Script -ExitCode 1605
- }
- }
- Function UpdatePrefs {
- $regPath = 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList'
- Get-ChildItem -path $regPath|
- ForEach-Object {
- $InstallPrefsDir = "AppData\Roaming\Wireshark"
- $StringValue = (Get-ItemProperty -path (join-path -path $regPath -child $_.pschildName) `
- -Name profileImagePath).profileImagePath
- $DataValOld = "#gui.update.enabled: TRUE"
- $DataValNew = "gui.update.enabled: FALSE"
- $OldInstallPrefsFile = $StringValue + "\" + $InstallPrefsDir + "\preferences"
- #$NewnstallPrefsFile = ".\SupportFiles\preferences"
- $NewnstallPrefsFile = "$PWD\SupportFiles\preferences"
- #if ( ! (Test-Path -Path $OldInstallPrefsFile -IsValid ) ) {
- if ((Test-Path $OldInstallPrefsFile) -eq $true ) {
- (Get-Content $OldInstallPrefsFile ) | foreach-object {$_ -replace $DataValOld, $DataValNew} | Set-Content $NewnstallPrefsFile
- }
- Else {
- Copy-Item -Path $NewnstallPrefsFile -Destination $StringValue\$InstallPrefsDir
- }
- }
- }
- Function OverwritePrefs {
- $regPath = 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList'
- Get-ChildItem -path $regPath|
- ForEach-Object {
- $InstallPrefsDir = "AppData\Roaming\Wireshark"
- $StringValue = (Get-ItemProperty -path (join-path -path $regPath -child $_.pschildName) `
- -Name profileImagePath).profileImagePath
- $NewnstallPrefsFile = "$PWD\SupportFiles\preferences"
- Copy-Item -Path $NewnstallPrefsFile -Destination $StringValue\$InstallPrefsDir
- }
- }
- Function StatusInstall {
- if ($InstallName -and $InstallVersion) {
- Show-InstallationPrompt -Message "The installation of $DisplayName $DisplayVersion complete." -ButtonMiddleText 'OK' -Icon Information -NoWait
- } else {
- Write-Log -Message "$DisplayName $DisplayVersion failed to install."
- Show-InstallationPrompt -Message "Error! The installation of $DisplayName $DisplayVersion Failed." -ButtonMiddleText 'OK' -Icon Error -NoWait
- }
- }
- Function StatusUninstall {
- if ($InstallName -and $InstallVersion) {
- Write-Log -Message "$DisplayName $DisplayVersion failed to uninstall."
- Show-InstallationPrompt -Message "Error! The uninstallation of $DisplayName $DisplayVersion Failed." -ButtonMiddleText 'OK' -Icon Error -NoWait
- } else {
- Show-InstallationPrompt -Message "The uninstallation of $DisplayName $DisplayVersion complete." -ButtonMiddleText 'OK' -Icon Information -NoWait
- }
- }
- ##*===============================================
- ##* END FUNCTION LISTINGS
- ##*===============================================
- ##*===============================================
- ##* SCRIPT BODY
- ##*===============================================
- If ($scriptParentPath) {
- Write-Log -Message "Script [$($MyInvocation.MyCommand.Definition)] dot-source invoked by [$(((Get-Variable -Name MyInvocation).Value).ScriptName)]" -Source $appDeployToolkitExtName
- }
- Else {
- Write-Log -Message "Script [$($MyInvocation.MyCommand.Definition)] invoked directly" -Source $appDeployToolkitExtName
- }
- ##*===============================================
- ##* END SCRIPT BODY
- ##*===============================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement