I am trying to append to two log files at the same time. I am currently having to repeat the output and the append command >>
twice which is giving me repeat code:
$log1 = "C:\log1.txt"
$log2 = "C:\log2.txt"
$output = "Some output to be logged"
$output >> $log1
$output >> $log2
I have looked into using the Tee-Object
command and have come up with the following:
$output | Tee $log1 >> $log2
But this overwrites the first ($log1
) and appends to the second ($log2
). So my question is how I get $log1
not to be overwritten just appended too?
Related question:
how-to-redirect-a-output-of-a-command-to-two-files
Any help is appreciated, thanks.