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

How to debug a PowerShell script in a CA

Hi,
I am creating a Basic MSI project with InstallShield 2014. I am using a CA that will execute a PowerShell script to install IIS on a Server 2008 R2 (64 bit).
When I run the script manually in the PowerShell windows, IIS is installed correctly.
When it is run from the installer nothing is installed.
The log of the MSI show no errors

MSI (c) (B0:70) [08:00:07:689]: Doing action: CA_Install_IIS_Power
Action 8:00:07: CA_Install_IIS_Power.
Action start 8:00:07: CA_Install_IIS_Power.
MSI (c) (B0:4C) [08:00:07:692]: Invoking remote custom action. DLL: C:\Users\ADMINI~1\AppData\Local\Temp\2\MSIE1FE.tmp, Entrypoint: PS1
InstallShield 8:00:07: Beginning Run PowerShell...
InstallShield 8:00:15: Finished Run PowerShell
Action ended 8:00:15: CA_Install_IIS_Power. Return value 1


I have followed the steps described here http://helpnet.flexerasoftware.com/installshield19helplib/helplibrary/CAPowerShell.htm
And set the IS_PS_EXECUTIONPOLICY property to Unrestricted The script is stored in the binary table

How can I debug a PS running from a CA?

Here is the script
# Loading Feature Installation Modules
# --------------------------------------------------------------------
Import-Module ServerManager
# --------------------------------------------------------------------
# Installing IIS
# --------------------------------------------------------------------
Add-WindowsFeature -Name Web-Common-Http,Web-Asp-Net,Web-Net-Ext,Web-ISAPI-Ext,Web-ISAPI-Filter,Web-Http-Logging,Web-Request-Monitor,Web-Basic-Auth,Web-Windows-Auth,Web-Filtering,Web-Performance,Web-Mgmt-Console,Web-Mgmt-Compat,RSAT-Web-Server,WAS -IncludeAllSubFeature


Thank you

Sascha
Labels (1)
0 Kudos
(6) Replies
MichaelU
Level 12 Flexeran
Level 12 Flexeran

I'm not 100% sure, but I think our PowerShell support launches a 32-bit PowerShell engine. On the other hand, I'm pretty sure that modifying Windows Features requires the same bitness as the operating system, so would require a 64-bit PowerShell engine. Could you try explicitly invoking a 64-bit PowerShell engine, or check out the Windows Feature support in the Suite/Advanced UI project type?
0 Kudos
sschantz
Level 3

I did create a Lunch EXE CA that run the following stored in the directory table.
I have created a directory path POWER_SHELL that is set to :C:\Windows\System32\WindowsPowerShell\v1.0
The command I execute is : powershell.exe -ExecutionPolicy RemoteSigned -file "[SUPPORTDIR]\InstallIIS.ps1"

Still this is not installing the IIS and no error is logged in the MSI log file.

MSI (c) (BC:E8) [08:29:23:073]: Doing action: CA_Install_IIS_Power_EXE
Action 8:29:23: CA_Install_IIS_Power_EXE.
Action start 8:29:23: CA_Install_IIS_Power_EXE.
Action ended 8:29:31: CA_Install_IIS_Power_EXE. Return value 1.


Is this the proper way to call powershell?



Thank you

Sascha
0 Kudos
MichaelU
Level 12 Flexeran
Level 12 Flexeran

I'm no PowerShell expert, but that looks reasonable on the surface. Except for one thing: if your package is a 32-bit package, this will be redirected to launch C:\Windows\SysWow64\WindowsPowerShell\v1.0\powershell.exe instead of the System32 path. That is, it will still run a 32-bit PowerShell.
0 Kudos
sschantz
Level 3

So then, how do I force a 32-bit package to call the 64 bit version of a OS command?
0 Kudos
DLee65
Level 13

My guess is that you may be running into a path substitution issue.

Looking at my VMWare image of Windows 7x64 I see that the x86 version uses the following path:

%SystemRoot%\syswow64\WindowsPowerShell\v1.0\powershell.exe

x64 uses the System path you specified in your previous post. I wonder if the installer is seeing that you are a 32bit app and so does substitution to the path above? I am not sure of what the right answer is here, but, if this IS the case, then I would create a custom InstallScript action that sets a new directory path to the one you desire. InstallScript has the ability to specify "REGDB_OPTIONS = REGDB_OPTIONS | REGDB_OPTION_WOW64_64KEY;"

I used this approach to determine if our database instance exists in a x86 or x64 version of SQL Server.

For more information open help and look at the section for "Targeting 64-Bit Operating Systems with InstallScript Installations". There is a constant 'WOW64FSREDIRECTION' that can be used with the Disable and Enable to disable the file system reflection.

Again, this is ONLY a guess on my part based on what I am reading as to what might be going on. Hopefully it helps to find a solution.
0 Kudos
sschantz
Level 3

Hi,

I have found a way to get the PowerShell script to be run from a CA.

Following Lee suggestion, I have created a InstallScript CustomAction that will call an InstallScript function.
Here is a snippet of the IS Function:

sCommand = "-ExecutionPolicy RemoteSigned -file \""+p_sPowerScriptFile+"\"";
Disable(WOW64FSREDIRECTION);
nResult = LaunchAppAndWait (WINSYSDIR64^"WindowsPowerShell\\v1.0\\powershell.exe", sCommand, LAAW_OPTION_WAIT | LAAW_OPTION_USE_SHELLEXECUTE);
Enable(WOW64FSREDIRECTION);


Now the PowerShell script gets executed with no error.

Thank you all for your input.

Sascha
0 Kudos