View Single Post
Old 04-10-2007   #2 (permalink)
Marcel J. Ortiz [MSFT]


 
 

Re: No output from write-output

> Why didn't I get a line saying
> I got World


Because write-output doesn't write to the console. It sends objects down
the pipeline which measure-command will then discard. measure-object will
only output the TimeSpan object for how long it took. write-host will write
to the console.
So if you change write-output to write-host you'll get what you expected.


"DouglasWoods" <DouglasWoods@discussions.microsoft.com> wrote in message
newsE5409AF-3797-48C3-9462-7E80D105081E@microsoft.com...
>I have this script, which does not run as I expected.
> ----------------------------------------
> function foo($bar)
> {
> write-output "I got $bar"
> }
>
> foo "Hello"
> measure-command {foo "World"}
> ---------------------------------------
>
> Here is the ouput.
>
> ---------------------------------------
> I got Hello
>
>
> Days : 0
> Hours : 0
> Minutes : 0
> Seconds : 0
> Milliseconds : 1
> Ticks : 15418
> TotalDays : 1.78449074074074E-08
> TotalHours : 4.28277777777778E-07
> TotalMinutes : 2.56966666666667E-05
> TotalSeconds : 0.0015418
> TotalMilliseconds : 1.5418
> --------------------------------------------------
>
> Why didn't I get a line saying
> I got World
>
> Douglas Woods


My System SpecsSystem Spec