title: How to set a PowerShell switch parameter from TeamCity build configuration
body: <p>I have a PowerShell script with a switch (boolean) parameter that I want to call from a TeamCity build step.</p>
  
  <p>I want the value of the switch (true/false) to be set according to a TeamCity build parameter, a configuration parameter.</p>
  
  <p>So, something like this:
  <img src="https://i.stack.imgur.com/ePPxk.png" alt="enter image description here"></p>
  
  <p>And in the PowerShell runner build step:
  <img src="https://i.stack.imgur.com/AvAe6.png" alt="enter image description here"></p>
  
  <p>But the above does not work.</p>
  
  <p>I get this error</p>
  
  <pre><code>[14:27:01][Step 1/1] Cannot process argument transformation on parameter 'preRelease'. Cannot 
  [14:27:01][Step 1/1] convert value "System.String" to type 
  [14:27:01][Step 1/1] "System.Management.Automation.SwitchParameter". Boolean parameters accept only 
  [14:27:01][Step 1/1] Boolean values and numbers, such as $True, $False, 1 or 0.
  </code></pre>
  
  <p>As you can see, it seems that PowerShell insist on interpreting the parameter as a string.</p>
  
  <p>I have tried many variants of writing the script argument. None of these work:</p>
  
  <pre><code>-preRelease:%IncludePreRelease%
  -preRelease:([boolean]%IncludePreRelease%)
  -preRelease:([System.Convert]::ToBoolean(%IncludePreRelease%))
  </code></pre>