This page has a good discussion on powershell output with some examples. I think output can always be avoided as Michael said.
http://keithhill.spaces.live.com/blog/cns!5A8D2641E0963A97!811.entry Jeff On Tue, Jan 19, 2010 at 2:45 PM, Joseph L. Casale <[email protected] > wrote: > >I may be dense this afternoon, but huh? > > Lol, > > Ok, an example (stupid, but an example)... > > Function Test_Time { > $a = Get-Date > If ($a.Minute -gt 30) { Return 1 } > Else { Return 0 } > } > > If (Test_Time) { Write-Host 'gt 30...' } > Else { Write-Host 'lt 30...' } > > > This works only by fluke as the only output is the return. > What if the function necessarily generates loads of output? > > > Function Test_Time { > $a = Get-Date > Get-Alias > If ($a.Minute -gt 30) { Return 1 } > Else { Return 0 } > } > > If (Test_Time) { Write-Host 'gt 30...' } > Else { Write-Host 'lt 30...' } > > > This always evals to true as a result of the slew of output that > gets written out. So how do you deal with this? I know I can hide > the output of that Get-Alias, but what if you can't avoid some output? > > Thanks! > jlc > > ~ Finally, powerful endpoint security that ISN'T a resource hog! ~ > ~ <http://www.sunbeltsoftware.com/Business/VIPRE-Enterprise/> ~ > > ~ Finally, powerful endpoint security that ISN'T a resource hog! ~ ~ <http://www.sunbeltsoftware.com/Business/VIPRE-Enterprise/> ~
