PowerShell cmdlet get-property used in a Custom Action
SummaryHow-To Example on getting MSI property from PowerShell script using InstallShield 2015 or newer
SynopsisIf you are using InstallShield 2015 or newer, you can use cmdlets, which will let you interact (get and set Windows Installer properties) with the running PowerShell custom action. This is a brief how-to and example getting and displaying a MSI Public Property using PowerShell .
When you craft the sample below you can expect to see a message box display the content of the property you set in the Windows Installer Property Table.
- Include/create a Windows Installer public property called MYPROPERTY in the Property Manager view.
- Add a value - some random string as the value of MYPROPERTY in the Property Manager view.
- In the view Custom Actions and Sequences include a New PowerShell custom action and click one of the following commands:
? Stored in Binary table?To have your code base stored in the Binary table, select this command. This location is useful if you do not want the file to be installed on the target system. ? Installed with product?To call code from a script file that is going to be installed on the target system, select this command.
- For this proof of concept (POC) schedule in the Install UI Sequence after CostFinalize.
- For this POC we are to use an empty .ps1 file. In the PowerShell Script File Name setting, select the PowerShell script file (.ps1) in the list of files that are stored in the Binary table or that are included in your project. If the location that you specified is stored in the Binary table, you can click this ellipsis button (...) in this setting to browse to the file.
- On the Script tab insert:
$VALUE = get-property -name MYPROPERTY [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms") [System.Windows.Forms.MessageBox]::Show($VALUE)
Related DocumentsFor more information see:
Calling a PowerShell Custom Action
Property Manager View