PowerShell 'Tee-Object' not working on 'rclone copy'

I’m getting back into scripting for rClone after a couple months away. I had written a few scripts that used ‘Tee-Object’ in Windows PowerShell and they worked without fault.

Recently, I can’t seem to get ‘Tee-Object’ to work anymore when using ‘rclone copy’. After a successful transfer, I can see the stats in the PowerShell window, but nothing was sent to my log file. I’ve tried using ‘Tee-Object’ after a quick ‘rclone ls’ and it logs the information just fine.

This command sends nothing to the log output:
> rclone copy “M:\Testing\rClone Test” testing: -v | Tee-Object -FilePath “F:\Logs\Test\testLog.log”

This command sends everything to the log output:
> rclone ls testing: | Tee-Object -FilePath “F:\Logs\Test\testLog.log”

Does anyone have any ideas as to why rclone copy isn’t working with Tee-Object?

Probably because rclone sends its logs to stderr not stdout.

You can use --log-file to send them to a file - but that probably isn’t what you want.

In bash you would add 2>&1 to your command line to direct stderr to the same place that stdout is going. Maybe powershell has something similar?

Thanks for the reply @ncw!

2>&1 works in PowerShell, but then I don’t get any of the logging stats in the actual PowerShell window. I was hoping to both see the progress in PowerShell, but Tee-Object into a log file.

I don’t quite know why Tee-Object would work when doing an ‘rclone ls’ but not work specifically when doing an ‘rclone copy’.

rclone ls puts its listing to stdout but the logs still go to stderr. rclone ls doesn’t normally generate logs though.