Using Powershell for Packaging Silent Application Installations - Including a Comparison to Equivalent Batch Commands
Deploying software within an enterprise often requires the additional step of packaging the application so that it installs silently and is properly configured to run within the enterprise. This configuration may include many different actions such as combining several different installation source files, adding parameters for proper licensing, or turning off automatic update features. To create an installation package that can be used to deploy the application within an enterprise software distribution system it's often useful to use a script wrapper that combines all the necessary actions.
Many different types of script wrappers are often used for packaging applications. For those who are considering which to use, powershell is an excellent choice. Most powershell commands that are used in packaging can be accomplished in a single simple line and therefore any later troubleshooting is that much easier.
To initially create powershell scripts, the easiest method is to launch Powershell ISE and use the top pane to write the script (on servers you may have to first add Powershell ISE as a feature). You can then test your script using the green "Play" button. Note that if you have UAC enabled on workstation and you would like to test your script using administrative credentials you might also want to perform the following steps:
- Close your original Powershell ISE console
- Search for the Powershell ISE icon, right-click on it, and select Run as Administrator
- For this test case, if you would also like to set the source path to allow use of other commands residing in the same directory as your script you can do that using the cd command to set the source directory
To get started creating packages ATTACHED is a spreadsheet listing Powershell commands that would be highly used when packaging and also listed is the equivalent batch command for those transitioning from using batch files.
Once you have created a powershell script to install an application, you will most likely want to deploy the application via an enterprise software distribution system such as System Center Configuration Manager 2007/2012. The process will be the same as when using other scripts except for several items that are unique to Powershell that are listed below.
- Powershell.exe should be called before the powershell script file
- The powershell script file should have a preceding .\ before it
- By default many clients that will be the eventual targets of the script may have the Powershell execution policy set to Restricted. This needs to be changed at runtime to allow the powershell script to run.
Taking these items into consideration a typical command line within an enterprise software distribution system such as System Center Configuration Manager 2007/2012 would be:
Powershell -executionpolicy Bypass -file .\<Powershell .ps1 script>
Using these techniques you should be on your way to using Powershell to assist distributing applications.
- Jim Riekse
Standard Packaging Powershell Commands and Batch Equivalent.xlsx