Reputation: 2301
I've got the following piece of code that runs a separate powershell script, passing some arguments as necessary.
& $UpdateAppConfig -webConfigPath $AppConfig -keyName SQLServer -keyValue $SQLServer | out-file $PSLogFile -append -Encoding Ascii
However, it isn't pushing out errors that may occur, just the successful output. Am I missing something from my out-file piping?
Upvotes: 0
Views: 47
Reputation: 46700
Out-File
does not redirect errors, only standard output. It essentially is an alias for the redirector >
. In its place you could use Start-Transcript
/Stop-Transcript
which captures all data to file.
Start-Transcript -Path $PSLogFile
& $UpdateAppConfig -webConfigPath $AppConfig -keyName SQLServer -keyValue $SQLServer
Stop-Transcript
Sure there is another answer about this but havent found it yet. You should also be able to do
& $UpdateAppConfig -webConfigPath $AppConfig -keyName SQLServer -keyValue $SQLServer *>> $PSLogFile
*>>
Would append all output to file. See more information from about_Redirectors
Have to check if that actually would work.
Upvotes: 1