cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

PowerShell cmdlet get-property used in a Custom Action

PowerShell cmdlet get-property used in a Custom Action

Summary

How-To Example on getting MSI property from PowerShell script using InstallShield 2015 or newer

Synopsis

If 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 .


Discussion

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.

Steps:

  1. Include/create a Windows Installer public property called MYPROPERTY in the Property Manager view.
  2. Add a value - some random string as the value of MYPROPERTY in the Property Manager view.
  3. 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.
  4. For this proof of concept (POC) schedule in the Install UI Sequence after CostFinalize.
  5. 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.
  6. On the Script tab insert:
    $VALUE = get-property -name MYPROPERTY
    
    [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
    [System.Windows.Forms.MessageBox]::Show($VALUE)

Related Documents

For more information see:

Calling a PowerShell Custom Action

Property Manager View
Was this article helpful? Yes No
No ratings
Comments

I Have tried the below commandline

$VALUE = get-property -name MYPROPERTY

But everytime it seems it is not able to load the assembly for powershell

 set-property -name CXS_IP_LOCAL -value $localIpAddress
set-property : The term 'set-property' is not recognized as the name of a cmdlet, function, script file, or operable
program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ set-property -name CXS_IP_LOCAL -value $localIpAddress
+ ~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (set-property:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException

I am scheduling this in a powershell custom action in immediate mode that gets executed on the click event of a dialog box.

can anyone help with which assembly I can make it work.

Version history
Last update:
‎Jun 06, 2018 02:59 AM
Updated by: