On Fri, Apr 12, 2013 at 11:33 PM, Joseph L. Casale
<jcas...@activenetwerx.com> wrote:
>>but I can't figure out how to tell it one parameter *depends* on another.
>
> Create your parameter set, then set the few that depend on each other to be
> mandatory?

  I guess the below somehow wasn't clear enough, as you're the second
person to suggest this.  :-)

On Fri, Apr 12, 2013 at 5:20 PM, Ben Scott <mailvor...@gmail.com> wrote:
> If I specify either parameter (or both) as
> Mandatory=$true, it becomes mandatory *always*, not just when -mailTo
> is present.

  So, if I do this

        [Parameter(Mandatory=$false,ParameterSetName='mailTo')] [string] 
$mailTo,

        [Parameter(Mandatory=$true,ParameterSetName='mailTo')] [string] 
$smtpHost,

then -smtpHost becomes mandatory *all* the time, even if I don't
specify -mailTo.  And I don't need an SMTP host if I'm not sending
mail, so that's wrong.  Conversely, if I do this

        [Parameter(Mandatory=$true,ParameterSetName='mailTo')] [string] $mailTo,

        [Parameter(Mandatory=$false,ParameterSetName='mailTo')] [string] 
$smtpHost,

then -mailTo becomes mandatory (which I don't want) *and* -smtpHost
*isn't* mandatory, ever.

  If I set them both mandatory, they're both always mandatory.

  And if I put them in the same parameter set, but don't make either
mandatory, neither is considered mandatory, ever.

-- 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 listmana...@lyris.sunbeltsoftware.com
with the body: unsubscribe ntsysadmin

Reply via email to