advanced function parameter mandatory only when switch used

by Feb 15, 2015

Hi Guys, 

Is there a build in way to make function parameter mandatory base on switch state?

 

like if switch "used" parameter need to be provided. 

I know that i can ask user for that while running the script but i am looking to achieve like

example 1) starting function without parameters  – ok

    c:> MyFunction
           "no parameters"

example 2) starting function with 'parameter1'  (not mandatory) – ok 

    c:> MyFunction -parameter1
           "parameter1 used"

example 3) starting function with 'switchParameter' make  'parameter2' mandatory
    c:> MyFunction -switchParameter
            cmdlet MyFunction at command pipeline position 1
            Supply values for the following parameters:
            parameter2:  

Any explanation, example or link to documentation where it will be explained highly welcome.

regards
hermitagup