title: Bind PowerShell function to parameter
body: <p>Is it possible in PowerShell (or even better in PowerShell Core) to bind a function to a parameter ValidateSet specified to the script?</p>
  
  <p>I want to bind the parameter options <code>a</code>, <code>b</code> and <code>c</code> to the functions <code>a_function</code> <code>b_function</code> and <code>c_function</code> to the variable <code>$firstcmd</code> or <code>$secondcmd</code> . Therefore if the script is called by</p>
  
  <pre><code>PS C:\ script.ps1 a
  </code></pre>
  
  <p>the function <code>a</code> is run.</p>
  
  <p>if the script is called by</p>
  
  <pre><code>PS C:\ script.ps1 a b
  </code></pre>
  
  <p>the functions <code>a</code> and <code>b</code> are run.</p>
  
  <p>The parameter definition at script start looks like this:</p>
  
  <pre><code>param([Parameter(Mandatory=$false)][String][ValidateSet('a',
                                                          'b',
                                                          'c')$firstcmd,
        [Parameter(Mandatory=$false)][String][ValidateSet('a',
                                                          'b', 
                                                          'c')$secondcmd,
       )
  
  function a_function {
      Write-Host "Hello a"
  }
  
  function b_function  {
      Write-Host "Hello b"
  }
  
  function c_function  {
      Write-Host "Hello c"
  }
  
  # here the "command option to function mapping" magic should happen
  </code></pre>