Link to home
Create AccountLog in
Avatar of eelou
eelou

asked on

How to log a Powershell .ps1 file when executing custom action in InstallShield

InstallShield 2014 MSI installer.   Executing a custom Action.  The command below executes ok.  I am making some changes to the .ps1 file and now see some red\error text that scrolls quickly by, in the command window.

File name and command line: = C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe "& \"[INSTALLDIR]Data\ConfigWebsit.ps1\""

I am fairly new to PowerShell, I did not write the scripts that I am trying to modify.

I am trying to log the output (total output, not just a line or two in the file).  If I add the following, the execution of the script, and the install, fails...

C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe "& \"[INSTALLDIR]Data\ConfigWebsit.ps1 > [INSTALLDIR]Configwebsit.ps1\""

This also fails...
C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe "& \"[INSTALLDIR]Data\ConfigWebsit.ps1 > [INSTALLDIR]Configwebsit.ps1 | Out-File 'C:\path\to\your.log'\""

Can this be done?
Avatar of Qlemo
Qlemo
Flag of Germany image

C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe "& \"[INSTALLDIR]Data\ConfigWebsit.ps1\" > \"[INSTALLDIR]Configwebsit.log\""

Open in new window

should work, as does
C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe "& '[INSTALLDIR]Data\ConfigWebsit.ps1' > '[INSTALLDIR]Configwebsit.log' "

Open in new window

and
C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe "& '[INSTALLDIR]Data\ConfigWebsit.ps1' | Out-File '[INSTALLDIR]Configwebsit.log' "

Open in new window

Avatar of eelou
eelou

ASKER

Making progress.  I used the first example, and did get a log file.  It does not though show the errors (that flashed by in red).  How can I get the errors, and\or both (good and bad)?
Avatar of eelou

ASKER

I combined what I got from you, and some of what I found online (it appears to work)...

C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe " & '[INSTALLDIR]Data\ConfigWebsit.ps1' 2>&1 | tee -filePath  '[INSTALLDIR]Configwebsit.log' "
ASKER CERTIFIED SOLUTION
Avatar of Qlemo
Qlemo
Flag of Germany image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account