redirection of output?<span style="line-height:115%;font-family:'Microsoft Sans Serif';color:#1f497d;font-size:10pt"><span style="color:#000000">I am running a command executible by calling: <br/><br/>$command = some.exe &lt; a bunch of parameters&gt;<br/>invoke-expression $command <br/><br/>If i pipe the output to files like this:<br/><br/>invoke-expression $command 2&gt;foo.txt &gt;bar.txt<br/><br/>errors go to foo.txt and regular output goes to bar.txt. now if I do this:<br/><br/>invoke-expression $command 2&gt;&amp;1&gt;bar.txt<br/><br/>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? <br/><br/>It seems like Tee-Object should have an option to also grab errors? what I would like to do is<br/><br/>invoke-expression $command | Tee-object -var $foo<br/><br/>then use $foo to try and recover from issues.</span></span>© 2009 Microsoft Corporation. All rights reserved.Thu, 25 Jun 2009 19:01:35 Zc8c6f2b3-0b05-4160-9997-2808eb012601http://social.technet.microsoft.com/Forums/en-US/winserverpowershell/thread/c8c6f2b3-0b05-4160-9997-2808eb012601#c8c6f2b3-0b05-4160-9997-2808eb012601http://social.technet.microsoft.com/Forums/en-US/winserverpowershell/thread/c8c6f2b3-0b05-4160-9997-2808eb012601#c8c6f2b3-0b05-4160-9997-2808eb012601Tim Estensonhttp://social.technet.microsoft.com/Profile/en-US/?user=Tim%20Estensonredirection of output?<span style="line-height:115%;font-family:'Microsoft Sans Serif';color:#1f497d;font-size:10pt"><span style="color:#000000">I am running a command executible by calling: <br/><br/>$command = some.exe &lt; a bunch of parameters&gt;<br/>invoke-expression $command <br/><br/>If i pipe the output to files like this:<br/><br/>invoke-expression $command 2&gt;foo.txt &gt;bar.txt<br/><br/>errors go to foo.txt and regular output goes to bar.txt. now if I do this:<br/><br/>invoke-expression $command 2&gt;&amp;1&gt;bar.txt<br/><br/>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? <br/><br/>It seems like Tee-Object should have an option to also grab errors? what I would like to do is<br/><br/>invoke-expression $command | Tee-object -var $foo<br/><br/>then use $foo to try and recover from issues.</span></span>Wed, 24 Jun 2009 12:50:06 Z2009-06-24T12:50:06Zhttp://social.technet.microsoft.com/Forums/en-US/winserverpowershell/thread/c8c6f2b3-0b05-4160-9997-2808eb012601#2c9aad07-9de9-4e73-b80f-ded9695b7bb7http://social.technet.microsoft.com/Forums/en-US/winserverpowershell/thread/c8c6f2b3-0b05-4160-9997-2808eb012601#2c9aad07-9de9-4e73-b80f-ded9695b7bb7Marco Shawhttp://social.technet.microsoft.com/Profile/en-US/?user=Marco%20Shawredirection of output?Not sure what version of PowerShell you're trying...<br/> <br/> I tried with v2 CTP3 and it still doesn't work...<br/> <br/> I'll ask around.  I don't find anything related in Microsoft Connect.Wed, 24 Jun 2009 16:15:49 Z2009-06-24T16:15:49Zhttp://social.technet.microsoft.com/Forums/en-US/winserverpowershell/thread/c8c6f2b3-0b05-4160-9997-2808eb012601#9d3b6b23-4c34-43ed-a32a-5035b192bd60http://social.technet.microsoft.com/Forums/en-US/winserverpowershell/thread/c8c6f2b3-0b05-4160-9997-2808eb012601#9d3b6b23-4c34-43ed-a32a-5035b192bd60Marco Shawhttp://social.technet.microsoft.com/Profile/en-US/?user=Marco%20Shawredirection of output?Known bug...<br/> <br/> You'll have to do this:<br/> <span style="line-height:115%;font-family:'Microsoft Sans Serif';color:#1f497d;font-size:10pt"><span style="color:#000000">(invoke-expression $command) 2&gt;&amp;1&gt;bar.txt</span> </span> <br/> <br/> Tee isn't designed to capture an error stream.Thu, 25 Jun 2009 19:01:28 Z2009-06-25T19:01:28Z