title: Mutually exclusive powershell parameters
body: <h2>SCENARIO</h2>
  
  <ul>
  <li>I'm writing a cmdlet for Powershell 2.0 using Visual Studio 2008 and .NET 3.5</li>
  <li>the cmdlet requires 3 arguments. </li>
  </ul>
  
  <p>my intended grammar of the cmdlet is something like this: </p>
  
  <pre><code>cmdletname [foo|bar] p1, p2
  </code></pre>
  
  <ul>
  <li>That reads as the user must give a value for "-foo" or "-bar" but can't give both together.</li>
  </ul>
  
  <h2>EXAMPLE OF VALID INPUT</h2>
  
  <pre><code>cmdletname -foo xxx -p1 hello  -p2 world
  cmdletname -bar yyy -p1 hello  -p2 world
  </code></pre>
  
  <h2>EXAMPLE OF INVALID INPUT</h2>
  
  <pre><code>cmdletname -foo xxx -bar yyy -p1 hello  -p2 world
  </code></pre>
  
  <h2>MY QUESTION</h2>
  
  <ul>
  <li>My question is on how to do this in powershell so that it does all the checking for me - or if that is possible at all.</li>
  <li>I know I can use just have two optional parameters for foo and bar and simply do the error checking manually. That's how I have it implemented currently. </li>
  <li>Alternatively, I am interested in suggestions for different approaches.</li>
  </ul>