Community Forums
Results 1 to 5 of 5

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

  1. #1
    Join Date
    Jun 2014
    Posts
    1

    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/i...PowerShell.htm
    Last edited by Chris.Conner; 09-12-2018 at 04:29 PM. Reason: mentioned that PS1 file is digitally signed and added link to help documentation that I used.

  2. #2
    Join Date
    Apr 2008
    Posts
    43
    Quote Originally Posted by Chris.Conner View Post
    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/i...PowerShell.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:

    Code:
    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.

  3. #3
    Join Date
    Apr 2008
    Posts
    43
    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.

  4. #4
    Join Date
    Apr 2008
    Posts
    43
    Quote Originally Posted by DonAIR View Post
    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.

  5. #5
    Join Date
    Jan 2002
    Location
    Probably on a plane somewhere or in a hotel room.
    Posts
    430
    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:

    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]).
    2. Schedule this new action to run in the InstallExecute sequence early in the sequence (I recommend prior to the InstallInitialize action).
    3. 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?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •