PowerShell Tee-Object also verbose logging

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

1

1 Answer

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

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

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

You Might Also Like