title: Powershell script that depends on another parameter
body: <p>This has been posted once before, but the proposed solution didn't solve my problem. I'm writing a script, and I want one of my parameters to be mandatory, but I only want it to be mandatory if one of the earlier parameters has a certain value.</p>
  
  <p>Example:</p>
  
  <pre><code>param([Parameter(Mandatory=$true, Position=0)]
    [ValidateSet("Add","Delete")]
    [string]$Command,
  
    [Parameter(Mandatory=$true)]
    [string]$Subject
  )
  </code></pre>
  
  <p>I want the Subject parameter to be required only if the Command parameter has the value "Add".</p>
  
  <p>I've tried using a ParameterSetName value, but that didn't seem to work.</p>