- Revenera Community
- :
- InstallShield
- :
- InstallShield Knowledge Base
- :
- PowerShell cmdlet get-property used in a Custom Action
- Mark as New
- Mark as Read
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
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 newerSynopsis
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:
- 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 Documents
For more information see:Calling a PowerShell Custom Action
Property Manager View
- Mark as Read
- Mark as New
- Permalink
- Report Inappropriate Content
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.