Can you? Yes.
filter Out-Default{ $_ | Out-File 'C:\logfile.txt' -append }
Now all output will go to the log file by default. Remove the temporary definition via
dir function:\Out-Default | del
But this is very hacky, non-obvious, and difficult to maintain, so I would not recommend it. It would be better to define a simple dedicated logging function, so that you only needed to add | log
to the relevant lines of the script. Much better to have a bit of extra code that is obvious to understand, debug, and change, than to add hacks just to "simplify" the code.
Out-Default
, that does what you want it to, will that replace the defaultOut-Default
?