PowerPacks
Not sure which scripting surface to use? See Automation and scripting for how PowerPacks, the VB Scripting Library, and the SDK compare.
Script templates
Section titled “Script templates”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:
PreInstall(orPreUninstall).- Start-PSDownloadPackage, if
$global:DownloadPackageis$trueand the script runs through the CapaInstaller agent. Install(orUninstall).PostInstall(orPostUninstall).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’sHResultas the exit code.
In this section
Section titled “In this section”- Add-PSDll
- $cs.File_AppendToFile
- $cs.File_CopyFile
- $cs.File_CopyTree
- $cs.File_CreateDirectory
- $cs.File_DelEmptyFolder
- $cs.File_DeleteLineInFile
- $cs.File_DelFile
- $cs.File_DelTree
- $cs.File_ExistDir
- $cs.File_ExistFile
- $cs.File_FindFile
- $cs.File_GetFileVersion
- $cs.File_GetFolderSize
- $cs.File_GetProductVersion
- $cs.File_RenameDir
- $cs.File_RenameFile
- $cs.Ini_ReadEntry
- $cs.Ini_WriteEntry
- $cs.Job_DisableLog
- $cs.Job_EnableLog
- $cs.Job_RebootWS
- $cs.Job_Start
- $cs.Job_WriteLog
- $cs.Log_SectionHeader
- $cs.MSI_GetProductCodeFromMSI
- $cs.MSI_GetPropertiesFromMSI
- $cs.MSI_GetPropertyFromMSI
- $cs.MSI_IsMSIFileInstalled
- $cs.MSI_IsMSIGuidInstalled
- $cs.Reg_CreateKey
- $cs.Reg_DeleteVariable
- $cs.Reg_DelTree
- $cs.Reg_EnumKey
- $cs.Reg_ExistKey
- $cs.Reg_ExistVariable
- $cs.Reg_GetExpandString
- $cs.Reg_GetInteger
- $cs.Reg_GetMultiString
- $cs.Reg_GetString
- $cs.Reg_SetDword
- $cs.Reg_SetExpandString
- $cs.Reg_SetInteger
- $cs.Reg_SetQword
- $cs.Reg_SetString
- $cs.Service_Exist
- $cs.Service_Start
- $cs.Service_Stop
- $cs.Shell_Execute
- $cs.Shell_ExecuteWithTimeout
- $cs.Sys_ExistProcess
- $cs.Sys_GetFreeDiskSpace
- $cs.Sys_IsMinimumRequiredDiskspaceAvailable
- $cs.Sys_isUserLoggedOn
- $cs.Sys_KillProcess
- $cs.Sys_Sleep
- $cs.Sys_WaitForProcess
- $cs.Sys_WaitForProcessToExist
- $cs.UsrMgr_AddUserToLocalGroup
- $cs.UsrMgr_ChangePassword
- $cs.UsrMgr_CreateLocalUser
- $cs.UsrMgr_DeleteLocalUserAccount
- $cs.UsrMgr_EnumMembersOfLocalGroup
- $cs.UsrMgr_ExistLocalUserAccount
- $cs.UsrMgr_GetNameBySid
- $cs.UsrMgr_RemoveUserFromLocalGroup
- Exit-PSScript
- Initialize-Variables
- $InputObject.CloseMessageBox
- $InputObject.ShowMessageBox
- Invoke-RunAsLoggedOnUser
- PowerPack Global Variables
- PowerPack tips and examples
- PowerShell CMS Functions
- Start-PSDownloadPackage