In my line of work, knowledge of how installations work is crucial. And with that knowledge, comes experience making terrible vendor installations work properly in an enterprise environment. For years, the standard solution, when troubleshooting and experimenting was going nowhere, was to repackage the troublesome app. Where experimenting lead somewhere, there might have been an eventual VB script written to cater for all the complexities involved to get everything working properly.
Some of the common challenges were
- Show a nice interface to let users know something was happening, for silent installs
- Install admin (system context) and user level files or registry keys, from the same script.
- Return proper error codes back to the deployment system (commonly SCCM)
- Link together several installations
- Switch between install types (interactive, passive or silent; pulled install, task sequence, server install, etc)
These were common problems, and in some cases, you had to make several installation scripts, to cater for different scenarios. Ok, if you had enough time, you could create a script that accepted certain parameters on launch, to do different things. But in the rush to meet SLAs, you would do the most urgent thing first, and then go back to revisit the app later, when a different scenario was needed.
Which is why I was happy to find the PowerShell App Deployment Toolkit, as a common deployment toolkit to help with the common packaging and deployment issues.
First, let me just say, the PowerShell App Deployment Toolkit is often excessive for simpler tasks. Alternatives within your deployment system, such as dependencies in SCCM 2012, can usually meet your requirements more efficiently. Also, this does mean you need to learn PowerShell. PowerShell looks complicated initially, more so if you are used to the syntax of scripting languages such as VB script. However, it is not hard to learn. This MVA course is a good starting point, if you are already familiar with other scripting languages.
You will also need to have a good understand of what you need to do. Investigate what preconditions needs to be checked, what the installation steps are, what post installation steps there are, and also the same for uninstalling the application.
The layout of the toolkit is pretty simple.
- Toolkit folder. Files and configurations for the toolkit
- Files folder (for your application files)
- Deploy-Application.exe (the entry point)
- Deploy-Application.exe.config
- Deploy-Application.ps1 (the main script, which you will edit)
You put all your application files in the Files folder. You then edit Deploy-Application.ps1 to put in the necessary logic needed. The Deploy-Application.ps1 structure may look complex initially, but it actually pretty simple
- Variable section. Application name, version, vendor, etc.
- Pre Installation. Steps before running the installation
- Installation. Installation steps
- Post Installation. Steps after installing the application
- Pre Uninstallation. Steps before running the uninstallation
- Uninstallation. Uninstallation steps
- Post Uninstallation. Steps after uninstalling the application
In the simplest sense, here is the bits you modify to get a working installation.
[powershell]
##*===============================================
##* VARIABLE DECLARATION
##*===============================================
## Variables: Application
[string]$appVendor = 'Microsoft'
[string]$appName = 'Visual C++ Runtime'
[string]$appVersion = '2013'
[string]$appArch = 'x86'
[string]$appLang = 'EN'
[string]$appRevision = '01'
[string]$appScriptVersion = '1.0.0'
[string]$appScriptDate = '02/06/2015'
[string]$appScriptAuthor = 'My Name'
##*===============================================
##Some code i did not need to modify omitted.
##*===============================================
##* INSTALLATION
##*===============================================
[string]$installPhase = 'Installation'
## <Perform Installation tasks here>
Execute-Process -Path 'vcredist.exe' -Parameters '/passive /norestart'
##Some code i did not need to modify omitted.
##*===============================================
##* UNINSTALLATION
##*===============================================
[string]$installPhase = 'Uninstallation'
# <Perform Uninstallation tasks here>
Execute-Process -Path 'vcredist.exe' -Parameters '/uninstall /passive /norestart'[/powershell]
That is! Now, to actually run the app, you run Deploy-Application.exe.
Installation:
Deploy-Application.exe -DeploymentType "Install"
You don’t actually need to use the DeploymentType switch for installation, as that would be the default
Uninstallation:
Deploy-Application.exe -DeploymentType "UnInstall"
That should be sufficient to get you started. You can download the toolkit and try it out. The included documentation is enough to help you understand how each function in the toolkit works.
This looks far too simple, I know. I’ll be adding another post with more examples to try and really make use of the toolkit to solve problems.