Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

redirection of output?

$
0
0
I am running a command executible by calling:

$command = some.exe < a bunch of parameters>
invoke-expression $command

If i pipe the output to files like this:

invoke-expression $command 2>foo.txt >bar.txt

errors go to foo.txt and regular output goes to bar.txt. now if I do this:

invoke-expression $command 2>&1>bar.txt

I expect both errors and output to be interlaced into the same file. However in reality the errors are completly lost. Is this a bug?

It seems like Tee-Object should have an option to also grab errors? what I would like to do is

invoke-expression $command | Tee-object -var $foo

then use $foo to try and recover from issues.

Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>