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

InstallShield / PowerShell interaction not consistant

I am working on a Suite install that runs a PowerShell script on Begin. It reads default property values from a text file and stores them in the Suite Properties.
However, the results are inconsistent from run to run. Sometimes none of the PS commands execute, sometimes several, but never more than the second set-suiteproperty command.
I found this similar to another post by DLee on 1/9/14, but I'm not sure if it is the same. I am also running on Windows 7x86; I will try to upgrade to Windows 7x64 as soon as possible.

Has anyone else run into this issue; and did upgrading to x64 solve the problem? What about other OS versions?

PS Script snippet
trace-suiteinfo -LogMessage "ReadDefaultsScript:INFO - Import interview parameters."

# Read the installation parameters from the parameter file into the installer properties.
$hostid = get-content -Path InstallParameters.txt | Select-String "HOSTID = "
$hostid = $hostid -creplace "HOSTID = ", ""
trace-suiteinfo -LogMessage "ReadDefaultsScript:INFO - Retrieved HOSTID = $hostid."
set-suiteproperty -name HOSTID -value $hostid
$test = get-suiteproperty -name HOSTID
trace-suiteinfo -LogMessage "ReadDefaultsScript:INFO - Stored HOSTID = $test."

$dvakey = get-content -Path InstallParameters.txt | Select-String "DVAKEY = "
$dvakey = $dvakey -creplace "DVAKEY = ", ""
set-suiteproperty -name DVAKEY -value $dvakey
trace-suiteinfo -LogMessage "ReadDefaultsScript:INFO - DVAKEY = $dvakey."
$test = get-suiteproperty -name DVAKEY
trace-suiteinfo -LogMessage "ReadDefaultsScript:INFO - Stored DVAKEYE = $test."

$sitecode = get-content -Path InstallParameters.txt | Select-String "SITECODE = "
$sitecode = $sitecode -creplace "SITECODE = ", ""
set-suiteproperty -name SITECODE -value $sitecode
trace-suiteinfo -LogMessage "ReadDefaultsScript:INFO - SITECODE = $sitecode."
$test = get-suiteproperty -name SITECODE
trace-suiteinfo -LogMessage "ReadDefaultsScript:INFO - Stored DITECODE = $test."

Corresponding Log File Snippet
5-20-2014[10:28:09 AM]: Running event 'ReadParametersScript'
5-20-2014[10:28:09 AM]: Engine: request for proxy handler, 0, 0
5-20-2014[10:28:11 AM]: (PowerShell Action): Attempting to load through CLR 4 APIs...
5-20-2014[10:28:11 AM]: (PowerShell Action): Getting meta host...
5-20-2014[10:28:11 AM]: (PowerShell Action): Enumerating available runtimes...
5-20-2014[10:28:11 AM]: (PowerShell Action): Highest available runtime: v4.0.30319
5-20-2014[10:28:11 AM]: (PowerShell Action): Trying to use highest runtime...
5-20-2014[10:28:11 AM]: (PowerShell Action): Using highest version runtime...
5-20-2014[10:28:16 AM]: (PowerShell Action): ReadDefaultsScript:INFO - Import interview parameters.
5-20-2014[10:28:18 AM]: (PowerShell Action): ReadDefaultsScript:INFO - Retrieved HOSTID = 02-5C-02-02-05.
5-20-2014[10:28:18 AM]: Engine: property 'HOSTID' value now '02-5C-02-02-05'
5-20-2014[10:28:18 AM]: (PowerShell Action): ReadDefaultsScript:INFO - Stored HOSTID = 02-5C-02-02-05.
5-20-2014[10:28:18 AM]: Engine: property 'DVAKEY' value now '49b9c62d'
5-20-2014[10:28:18 AM]: (PowerShell Action): ReadDefaultsScript:INFO - DVAKEY = 49b9c62d.
5-20-2014[10:28:18 AM]: (PowerShell Action): ReadDefaultsScript:INFO - Stored DVAKEYE = 49b9c62d.
5-20-2014[10:28:19 AM]: Action returned value 0x00000000
5-20-2014[10:28:19 AM]: Action 'ReadParametersScript' returned status 0x00000000
Labels (1)
0 Kudos
3 Replies
Level 13

Unless you can be sure of your environment and if it includes PowerShell by default, I would avoid using PS scripts because operating systems like Vista and Server 2008 do not have it enabled by default.

That does not explain the windows 7 problem however, because Windows 7 does have it enabled by default. So I would look at your script. Do a test to confirm that the file exists prior to get-content possibly. I am not certain, just brain storming.

What I would recommend is using an InstallScript custom action because it does not depend on PS being installed. I am sure you can modify a text file using that.
0 Kudos
Level 2

Thanks Dan! Part of the pre-install procedures are to ensure that PS v3.0 is installed and execution policy is set to unrestricted; so I shouldn't have a problem with PS.
What I found is that making the set-suiteproperty call is problematic. Sometimes it works and sometimes it doesn't (as shown in the log file). The text file is copied to the install directory in the same bat file I use to run setup with the /debug log file command, so I know that it exists.

Since I am just learning IS, I have yet to figure out how to make a custom action at the Suite level; all I can find to invoke are set properties, DLL calls, PS scripts, or executable installs. Any suggestions are appreciated.

Bret Dotts
0 Kudos
Level 13

I should have taken a closer look at the log file :D, you are correct in your assumptions. The text file must exist since the HOSTID is obtained and reconfigured.
Unfortunately I forget if I ever solved my PS issues because I did switch to InstallScript. I can certainly appreciate the fact that InstallShield and more importantly InstallScript is new to you.
With IS2013 the InstallScript custom action was not 'baked' into the application. Because of this, I had to script my changes as a separate project and then manually edit the .suite project in notepad++, or you could use an XML editor if you have that available.

Here is a link to the InstallTalk blog.

I looked through my PS1 file and could not find anything really different between mine and yours in terms of implementing the write to log file and setting the property value.

Since InstallScript is not familiar to you, I do not know if you are comfortable with scripting a C++ custom action. The link below shows how to create a C++ custom action for MSI. I think the help documentation for 2013 has information specific to Suite projects.
0 Kudos