PowerShell App Deployment Toolkit

1. PowerShell App Deployment Toolkit

1.1 Introduction

The PowerShell App Deployment Toolkit provides a set of functions to perform common application deployment tasks and to interact with the user during a deployment.

It simplifies the complex scripting challenges of deploying applications in the enterprise, provides a consistent deployment experience and improves installation success rates.

The engine can be downloaded here: http://psappdeploytoolkit.com/


1.2 Sample

For example, let’s create an installation package for Adobe Flash Player.

Here is the installation process of the Flash Player package:

  • Installation of the ActiveX component (MSI + MST)
  • Installation of the Plugin component (MSI + MST)
  • Check of the OS architecture
    • If 64-bit: Copy mms.cfg file in both C:\System32 and C:\SysWOW64
    • If 32-bit: Copy mms.cfg file in C:\System32 only
  • Creation of the inventory registry entries


2. Package Structure

An installation package is composed of the following elements:


Deploy-Application.exe is the main launcher. It allows to run the ps1 file.

Deploy-Application.ps1 is the script which lists all actions to perform to install the package.


2.1 “AppDeployToolkit” Folder

The “AppDeployToolkit” folder contains the engine of the framework.

  • AppDeployToolkitBanner.png is the banner displayed on the GUI and must be sized 450×50 px.
  • AppDeployToolkitConfig.xml is the configuration file of the engine. It can be modified to change general settings of the engine (standard texts in the prompts, standard delay before timeout…)
  • Ps1 files are the engine itself.


2.2 “Files” Folder

The “Files” folder contains the setup files of the package (MSI, MST, EXE, config files…)



3. Deploy-Application.ps1

3.1 Variable Declaration

Variables used by the engine have to be defined.

## Variables: Application
[string]$appPackageName = 'Adobe_FlashPlayer'
[string]$appVendor = 'Adobe'
[string]$appName = 'Flash Player'
[string]$appVersion = 'xx.0.0.yyy'
[string]$appArch = ''
[string]$appLang = 'MUI'
[string]$appRevision = 'A'
[string]$appScriptVersion = '1.0'
[string]$appScriptDate = '08/03/2016'
[string]$appScriptAuthor = 'Dam Dbs'


3.2 Pre-Installation Phase

The “Pre-Installation phase” is used to perform all actions to execute before the installation of the package (kill processes, uninstall previous version…).

It can also be used to display prompts to the logged user before starting the installation.


3.2.1 Welcome Message


## Show Welcome Message
Show-InstallationPrompt -Title 'Flash Player Update' -Message "IT NOTIFICATION `n`n A Flash Player security update is required on your computer. `n`n Please click OK to launch the update, otherwise it will be automatically started in 1 hour." -ButtonRightText 'OK' -PersistPrompt -MinimizeWindows $true -Timeout 3600 -ExitOnTimeout $false -Icon Information


3.2.2 Close Application Message


## Show CloseApp Message, close Internet Explorer, Firefox and Chrome if necessary and avoid to launch them during installation
Show-InstallationWelcome -CloseApps 'iexplore,firefox,chrome' -PersistPrompt -BlockExecution -ForceCloseAppsCountdown 600


In this example, iexplore, firefox and chrome processes must be closed before installation.

The “BlockExecution” argument prevents the user to launch them during installation.

The “ForceCloseAppsCountdown” argument allows closing those processes at the end of the specified countdown.


3.2.3 Progress Message


## Show Progress Message (with the default message)


It’s the prompt displayed during the installation of the package.

The following tray balloon is also displayed:



3.3 Installation Phase

The “Installation phase” is used to install the package silently.

## Install the ActiveX component
Execute-MSI -Action Install -Path 'install_flash_player_active_x.msi' -Transform 'Adobe_FlashPlayerActiveX.mst'
## Install the Plugin component
Execute-MSI -Action Install -Path 'install_flash_player_plugin.msi' -Transform 'Adobe_FlashPlayerPlugin.mst'
##CFG file copy
If ($envOSArchitecture -eq "64-bit") {
	Write-Log "64-bit architecture detected, copying cfg file in SysWOW64 and System32"
	Copy-File -Path "$dirFiles\mms.cfg" -Destination "$envWinDir\SysWOW64\Macromed\Flash"
	Copy-File -Path "$dirFiles\mms.cfg" -Destination "$envWinDir\System32\Macromed\Flash"
Else {
	Write-Log "32-bit architecture detected, copying cfg file in System32"
	Copy-File -Path "$dirFiles\mms.cfg" -Destination "$envWinDir\System32\Macromed\Flash"


3.4 Post-Installation Phase

The “Post-Installation phase” is used for all post-actions to perform and display the end message.


3.4.1 Post-Actions

For example, implement the inventory in the registry:

## Set Registry Inventory
Set-RegistryKey -Key "HKEY_LOCAL_MACHINE\SOFTWARE\Packaging\$appPackageName" -Name 'Installation Date' -Value "$currentDate-$currentTime"
Set-RegistryKey -Key "HKEY_LOCAL_MACHINE\SOFTWARE\Packaging\$appPackageName" -Name 'Manufacturer' -Value "$appVendor"
Set-RegistryKey -Key "HKEY_LOCAL_MACHINE\SOFTWARE\Packaging\$appPackageName" -Name 'ProductName' -Value "$appName"
Set-RegistryKey -Key "HKEY_LOCAL_MACHINE\SOFTWARE\Packaging\$appPackageName" -Name 'Version' -Value "$appVersion"
Set-RegistryKey -Key "HKEY_LOCAL_MACHINE\SOFTWARE\Packaging\$appPackageName" -Name 'Package Version' -Value "$appRevision"


3.4.2 End Install Message


## Display a message at the end of the install
Show-InstallationPrompt -Message "Installation completed. `n`n Please restart your Computer as soon as possible." -ButtonRightText 'OK' -Icon Information -NoWait