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?
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Qlemo"Batchelor", Developer and EE Topic AdvisorCommented:
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

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

Open in new window

eelouAuthor Commented:
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)?
eelouAuthor Commented:
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' "
Qlemo"Batchelor", Developer and EE Topic AdvisorCommented:
tee-object is used to send output to both a variable or file and down the pipe (usually going into further processing or dumping as console output). You better want to use
C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe "& \"[INSTALLDIR]Data\ConfigWebsit.ps1\" 2>&1 > \"[INSTALLDIR]Configwebsit.log\""

Open in new window


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.