You can always avoid output, as far as I know.

Anything output by a function is put onto the pipe. That's by design.

Give me a specific example where you think you can't avoid output?

-----Original Message-----
From: Joseph L. Casale [mailto:[email protected]] 
Sent: Tuesday, January 19, 2010 2:46 PM
To: NT System Admin Issues
Subject: RE: Powershell return values

>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/>  ~

Reply via email to