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

Using get-propery and trace-info is not working in PowerShell PS1 file

I am using InstallShield 2018 SP1.

We currently have a PowerShell script that we execute with no issues. However, I had a new requirement to get some properties that are exposed in the install via a new PowerShell script.

However, it is not working.

Do I need to import a module into the PS1 file so that the get-property and trace-info work as advertised when InstallShield is executing the script in my Custom Action?

My custom action is a PowerShell Custom Action.
The file is installed on the system during the install (verified)
The file is marked as a key and it shows up in the CA under the "PowerShell Script FileKey"
The return processing is set to Synchronous (Check exit code)
In-Script Execution is set to Deferred Execution

I have the Install Exec sequence set to run after I register some com plus components.

The following does NOT work:

try {
$InstallLevel = Get-Property -Name INSTALLLEVEL
trace-info -LogMessage "[Create-DataLink.ps1] InstallLevel"

trace-info -LogMessage "[Create-DataLink.ps1] Running via InstallShield."
}
exit(0)

I excepted to see my trace messages in the log file - but I do not. 😞 I even tried commenting out the get-property and use the trace-info and I still do not see any output from this CA.

I have run the install via the Internal build and viewed the log and I just get nowhere.

Has anyone run into this or can tell me what is necessary to get this to work?

Thank you.

=-Chris

P.S. - The PS1 file is digitally signed as well. I am using the documentation from this link provided by Flexera: http://helpnet.flexerasoftware.com/installshield23helplib/installshield23helplib.htm#helplibrary/CAPowerShell.htm
Labels (1)
0 Kudos

(4) Replies
DonAIR
Level 6

Chris.Conner wrote:
I am using InstallShield 2018 SP1.

We currently have a PowerShell script that we execute with no issues. However, I had a new requirement to get some properties that are exposed in the install via a new PowerShell script.

However, it is not working.

Do I need to import a module into the PS1 file so that the get-property and trace-info work as advertised when InstallShield is executing the script in my Custom Action?

My custom action is a PowerShell Custom Action.
The file is installed on the system during the install (verified)
The file is marked as a key and it shows up in the CA under the "PowerShell Script FileKey"
The return processing is set to Synchronous (Check exit code)
In-Script Execution is set to Deferred Execution

I have the Install Exec sequence set to run after I register some com plus components.

The following does NOT work:

try {
$InstallLevel = Get-Property -Name INSTALLLEVEL
trace-info -LogMessage "[Create-DataLink.ps1] InstallLevel"

trace-info -LogMessage "[Create-DataLink.ps1] Running via InstallShield."
}
exit(0)

I excepted to see my trace messages in the log file - but I do not. 😞 I even tried commenting out the get-property and use the trace-info and I still do not see any output from this CA.

I have run the install via the Internal build and viewed the log and I just get nowhere.

Has anyone run into this or can tell me what is necessary to get this to work?

Thank you.

=-Chris

P.S. - The PS1 file is digitally signed as well. I am using the documentation from this link provided by Flexera: http://helpnet.flexerasoftware.com/installshield23helplib/installshield23helplib.htm#helplibrary/CAPowerShell.htm


How are you running the custom action etc? It definitely works as I have just implemented this in 2018 last week. Below is a snip-it of working code to Validate a remote machine entered during Dialog:


trace-info -LogMessage "Running PS-ValidateApplicationServer.ps1 Custom Action"

##########################################
# Set Variables
##########################################

$appserver = get-property -name APPSERVER
trace-info -LogMessage "appserver set to $appserver"

##########################################
# Run Validation
##########################################

$appservervalid = Test-Connection -ComputerName $appserver -Count 1 -Quiet
if ($appservervalid -eq $True){
trace-info -LogMessage "Application Server $appserver is reachable"
set-property -name APPSERVERVALID -value "True"
} Else {
$appservervalid = Test-Connection -ComputerName $appserver -Count 3 -Quiet
if ($appservervalid -eq $True){
trace-info -LogMessage "Application Server $appserver is reachable"
set-property -name APPSERVERVALID -value "True"
} Else {
trace-info -LogMessage "Application Server $appserver is not reachable"
}
}

exit(0)


So basically the powershell gets the dialog property, validates the machine via Test-Connection and sets a new property to True/False that installshield then checks and throws up an error if not valid.

I set my custom action to Immediate Execution (TS Aware) and it is triggered by the Next button on the dialog where the User inputs the servername.
0 Kudos
DonAIR
Level 6

Actually strike some of my message above. The code above works fine unless I trigger it via a Dialog. That is odd. So for me, I am running about 7 PowerShell CA's, and 3 are triggered by DoAction on a Dialog Next... those don't log for some reason despite the code working (the machine validates/fails as it should.
0 Kudos
DonAIR
Level 6

DonAIR wrote:
Actually strike some of my message above. The code above works fine unless I trigger it via a Dialog. That is odd. So for me, I am running about 7 PowerShell CA's, and 3 are triggered by DoAction on a Dialog Next... those don't log for some reason despite the code working (the machine validates/fails as it should.


Definitely a DoAction issue on the Dialog if you are using that, it worked fine when I moved it off a DoAction.
0 Kudos
dan_galender
Level 10

You say your custom action is a deferred mode custom action and you're trying to get the value of INSTALLLEVEL. Deferred custom actions only have access to 3 properties: ProductCode, UserSID, and CustomActionData. You'll need to do something like the following:

[LIST=1]
  • Create a SetProperty custom action that sets a property whose name is the same exact name as your custom action that needs the value, and set the value of the property to the value you want your deferred custom action to receive (like [INSTALLLEVEL]).
  • Schedule this new action to run in the InstallExecute sequence early in the sequence (I recommend prior to the InstallInitialize action).
  • In your deferred custom action, replace the property INSTALLLEVEL in your current Get-Property-Name statement to CustomActionData.

    See how that works for you.

    Also, I'm not a PowerShell guru, but in your first Trace-Info, I'd be surprised if the string doesn't contain the literal string InstallLevel. Wouldn't you want to concatenate the value of the $InstallLevel variable to the end of your message?
  • 0 Kudos