Skip to content

PowerPacks

Not sure which scripting surface to use? See Automation and scripting for how PowerPacks, the VB Scripting Library, and the SDK compare.

When you create a PowerPack in the CapaInstaller Console, it gets an install script and an uninstall script built from a template. Both scripts have the same sections:

Section What it contains Edit it?
Param block The parameters that CapaInstaller passes to the script: $Packageroot, $AppName, $AppRelease, $LogFile, $TempFolder, $DllPath and $InputObject. No
#### VARIABLES #### $global:DownloadPackage and $global:MinimumDiskspaceMB, followed by a # DO NOT CHANGE THESE VARIABLES block that copies the parameters into global variables. Only the two settings
#### FUNCTIONS #### PreInstall, Install and PostInstall in the install script, or PreUninstall, Uninstall and PostUninstall in the uninstall script. PreInstall and PreUninstall start with a free disk space check against $global:MinimumDiskspaceMB. Yes — your code goes here
#### MAIN #### Loads PSlib.psm1, runs Add-PSDll, $cs.Job_Start and Initialize-Variables, and then calls your functions. No

The two templates differ only in their function names and their defaults:

Setting Install template Uninstall template
$global:DownloadPackage $true $false
$global:MinimumDiskspaceMB 1500 0

#### MAIN #### runs the script in this order:

  1. PreInstall (or PreUninstall).
  2. Start-PSDownloadPackage, if $global:DownloadPackage is $true and the script runs through the CapaInstaller agent.
  3. Install (or Uninstall).
  4. PostInstall (or PostUninstall).
  5. Exit-PSScript 0. If any step throws an exception that your code doesn’t catch, the script ends instead with Exit-PSScript and the exception’s HResult as the exit code.