What happens if you remove the parentheses surrounding the "yt-dlp something"? Putting that inside parentheses will cause yt-dlp to run to completion (just as any code would because those parens say "do this first") before anything else happens.
Using tee-object with the output from an exe

I'm trying to record the output of yt-dlp to both a log file and see that output on screen. I thought tee
would let me do that. I have (yt-dlp something) *>&1 | tee filename.log
. It attempts to write the log file only after yt-dlp returns. Plus, nothing appears in the meantime. Do I have something wrong in my PowerShell code?
Windows Server PowerShell
3 additional answers
Sort by: Most helpful
-
Will Pittenger 306 Reputation points
2022-05-05T02:32:19.777+00:00 It was passing the rest of the line to yt-dlp. Or at least from what I could see. yt-dlp was complaining about a parameter it didn't know:
tee
. -
Rich Matheisen 47,861 Reputation points
2022-05-05T14:56:40.25+00:00 Try using an explicit reference to the EXE file. For example (this works):
PS C:\windows\system32> .\ping.exe 127.0.0.1 | tee c:\junk\x.txt
-
Will Pittenger 306 Reputation points
2022-05-05T14:58:01.207+00:00 I don't know why it seemed to be passing all that to yt-dlp. I took the parentheses out and it worked.