I am running a script, sometimes using "out-file" to catch messages, sometimes not.
In my script is a "write-host" cmdlt so I can see the messages and then I do a write-output cmdlt to ensure it is also in the out-file.
If I have not used an "out-file", I get the information twice on the screen.
To avoid this, can I detect if a running script is using "out-file"?
Then I could supress "write-output" when there is no out-file.