On Tue, Apr 16, 2013 at 12:14 PM, Michael B. Smith
<[email protected]> wrote:
> This should help. “msg” is just a function that logs all of its arguments to
> a text file.

  Hey... this is kind of a threadjack, but your sample code here makes
me think of it.

  In a PoSh script I'm evolving, I'm using functions to manage program
flow.  Some of these functions return values, which are captured into
variables by the caller.  But these functions also want to inform the
user of what's going on.  *And*, I'd also like to be able to
optionally redirect the output of the script as a whole, externally.
Is there a good way to do this?

  Write-Output writes to the main Powershell object pipeline, which
for functions, *is* the return value.  My in-band return value and my
out-of-band messages would get mixed together.

  Write-Host writes to the console, but cannot be redirected.

  Start-Transcript doesn't capture the output of external commands,
which makes it useless if you use such commands (and this script
does).

  Write-Verbose puts ugly "VERBOSE:" prefixes in front of everything,
and turns it all yellow.  (And cannot be redirected in PoSh ver 2.  I
can upgrade -- was thinking of doing so anyway -- but I haven't got
that far yet.)

  It's not real important to me right now, but I suspect it will be
some day, and this seemed like a good time to ask.  :-)

-- Ben

~ Finally, powerful endpoint security that ISN'T a resource hog! ~
~ <http://www.sunbeltsoftware.com/Business/VIPRE-Enterprise/>  ~

---
To manage subscriptions click here: 
http://lyris.sunbelt-software.com/read/my_forums/
or send an email to [email protected]
with the body: unsubscribe ntsysadmin

Reply via email to