I have set of powershell scripts which gets invoke from command prompt. Currently script returns the success or failure code.
Sometime some of the powershell commands in the scripts throws error. I want to capture all the output (logs/message/error). I found that I can use the command like
.\test.ps1 2>&1 | foreach-object {$_.ToString()} | Out-File e:\log.txt
Although this approch logs the error message however following are the problems
It just logs the error message not the line number which comes when I run the same script from the powershell console.
Now there is no output message from powershell. I do not want to hide the output from console & want powershell logging as additional thing.
I have to modify the script invocation command. Is there any standlone tool which can run & capture the output coming on the powershell window.