Fazer uma PerguntaFazer uma Pergunta
 

Respondidoredirection of output?

  • quarta-feira, 24 de junho de 2009 12:50Tim Estenson Medalhas de usuárioMedalhas de usuárioMedalhas de usuárioMedalhas de usuárioMedalhas de usuário
     
    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.

Respostas

Todas as Respostas

  • quarta-feira, 24 de junho de 2009 16:15Marco ShawMVP, ModeradorMedalhas de usuárioMedalhas de usuárioMedalhas de usuárioMedalhas de usuárioMedalhas de usuário
     
    Not sure what version of PowerShell you're trying...

    I tried with v2 CTP3 and it still doesn't work...

    I'll ask around.  I don't find anything related in Microsoft Connect.
  • quinta-feira, 25 de junho de 2009 19:01Marco ShawMVP, ModeradorMedalhas de usuárioMedalhas de usuárioMedalhas de usuárioMedalhas de usuárioMedalhas de usuário
     Respondido
    Known bug...

    You'll have to do this:
    (invoke-expression $command) 2>&1>bar.txt

    Tee isn't designed to capture an error stream.