I use Tee-Object to output my command to console and a file. I use this command:

Command 2>&1 | Tee-Object 'myfile.log'

With this command I only get standard and error output in my file. When a verbose output is send I do see it in the console but it doesn't end up in my logfile.

How can I output alle console info to a file? So also verbose messages.

I found this

 Pipeline (1) 
 Error    (2) 
 Warning  (3) 
 Verbose  (4) 
 Debug    (5)
 All      (*)

We still use the same operators
 >    Redirect to a file and replace contents
 >>   Redirect to a file and append to existing content
 >&1  Merge with pipeline output

So Command *> 'myfile.log' does the trick for my file but I don't see output in the console this way

  • Just a guess, but try command *>&1 | tee-object 'myfile.log' – SimonS May 15 '20 at 14:27
  • Yes that works.Maybe give it as an answer so I can accept it as the solution – Danny May 15 '20 at 14:35

You were actually already pretty close to your answer.

if that one worked Command 2>&1 | Tee-Object 'myfile.log' and you already found out that * instead of 2 would log everything, just do it that way:

Command *>&1 | Tee-Object 'myfile.log'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.