title: How to use a PowerShell variable as command parameter?
body: <p>I'm trying to use a variable as a command's parameter but can't quite figure it out.  Let's say <code>MyCommand</code> will accept two parameters: <code>option1</code> and <code>option2</code> and they accept boolean values.  How would I use <em>$newVar</em> to substitute option 1 or 2?  For example:</p>
  
  <pre><code>$newVar = "option1"
  MyCommand -$newVar:$true
  </code></pre>
  
  <p>I keep getting something along the lines of <em>'A positional parameter cannot be found that accepts argument '-System.String option1'</em>.</p>
  
  <hr>
  
  <p><strong>More Specifically:</strong><br>
  Here, the CSV file is an output of a different policy.  The loop goes through each property in the file and sets that value in my policy <em>asdf</em>; so  <code>-$_.name:$_.value</code> should substitute as <code>-AllowBluetooth:true</code>.</p>
  
  <pre><code>Import-Csv $file | foreach-object {
      $_.psobject.properties | where-object {
      # for testing I'm limiting this to 'AllowBluetooth' option
      if($_.name -eq "AllowBluetooth"){
      Set-ActiveSyncMailboxPolicy -Identity "asdf" -$_.name:$_.value
      }}
  }
  </code></pre>