PowerShell Script Template Files

AdminStudio 2021 | 21.0 | Application Manager

A PowerShell script template file, Deploy-Application.ps1, is provided in the following location:

   C:\AdminStudio Shared\PowerShellTemplate\

You can customize this script to meet your deployment requirements by editing it in the Windows PowerShell ISE application.

Figure 1:  PowerShell Script Template File, Deploy-Application.ps1, in Windows PowerShell ISE

This script is provided as a template to perform an install or uninstall of an application(s). The script either performs an “install” deployment type or an “uninstall” deployment type. The install deployment type is broken down into three main sections: Pre-Install, Install, and Post-Install. The script refers to the AppDeployToolkitMain.ps1 script which contains the logic and functions required to install or uninstall an application.

Contents of the PowerShellTemplate Directory

In addition to the Deploy-Application.ps1 template file, the PowerShellTemplate directory also includes these additional files:

File

Description

Deploy-Application.exe

Deploy-Application.exe.config

Executable that invokes a PowerShell script.

Deploy-Application.ps1

PowerShell script template file which is modified by the Wrap Package Wizard to contain the actual install logic for the specific package, including:

Installer Path

The variable corresponding is $dirFiles variables (toolkit variable found under, AppDeployToolkit\AppDeployToolkitMain.ps1).

Name

The variable corresponding is {appName}

Version

The variable corresponding is {appVersion}

Manufacturer

The variable corresponding is {appVendor}

Language

The variable corresponding is {appLang}

Install Command Line

The variable corresponding is {InstallPackage}

Uninstall Command Line

The variable corresponding is {UnInstallPackage}

For example, if Picasa.msi is the package to be wrapped, it's installer path would be: $dirFiles\Picasa.msi

AppDeployToolkit\AppDeployToolkitBanner.png

Banner image which can be customized to brand the PowerShell installer.

AppDeployToolkit\AppDeployToolkitLogo.ico

Image used when the PowerShell installer runs.

AppDeployToolkit\AppDeployToolkitConfig.xml

Contains configurable preferences for how the toolkit behaves, including language settings.

AppDeployToolkit\AppDeployToolkitExtensions.ps1

Script containing your extensions for the framework.

AppDeployToolkit\AppDeployToolkitMain.ps1

Main script with all functions.

AppDeployToolkit\AppDeployToolkitHelp.ps1

Help file explaining the functions.

AppDeployToolkit\AppDeployToolkitMain.cs

Additional functions.

Rules for a Custom PowerShell Template

If you are creating a custom PowerShell template file, observe the following rules:

Do not rename Deploy-Application.ps1—The Deploy-Application.exe application looks for a file named Deploy-Application.ps1. Therefore, if the .ps1 file name is changed to the package name or anything else, the install/uninstallation will fail.
Deploy-Application.ps1 must be in the root folder—The Deploy-Application.exe application expects the Deploy-Application.ps1 file to be present in the root folder level, the same folder that contains the Deploy-Application.exe file.
Installer package must be in the Files folder—The installer package (.msi or .exe) must be in the Files folder.
AppDeployToolkit must be in the root folder—The AppDeployToolkitfolder (along with all of its contents) must be in the root folder.

Note:Installation/uninstallation is not obstructed if the Deploy-Application.exe.config file is not present in the parent folder level or is even deleted.

Note:The $dirFiles variable includes the path to the installer package. If you change the value of this variable, installation will fail.