My gut would be to use variables, but then you need to create variables with a scope such that the variables exist outside of the function.
http://blogs.msdn.com/powershell/archive/2007/04/14/controlling-the-scop e-of-variables.aspx Running 'Get-Help Set-Variable' led me down this rabbit hole, for what it's worth. Good luck! -----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/> ~
