title: Powershell Switch Parameter to add to end of expression
body: <p>Here's what I'm trying to do:</p>
  
  <pre><code>param([Switch]$myparameter)
  If($myparamter -eq $true) {$export = Export-CSV c:\temp\temp.csv}
  Get-MyFunction | $export
  </code></pre>
  
  <p>If $myparameter is passed, export the data to said location. Else, just display the normal output (in other words, ignore the $export). What doesn't work here is setting $export to the "Export-csv...". Wrapping it in quotes does not work.</p>
  
  <p>I'm trying to avoid an if, then statement saying "if it's passed, export this. If it's not passed, output data"</p>
  
  <p>I have a larger module that everything works in so there is a reason behind why I am looking to do it this way. Please let me know if any additional information is needed.</p>
  
  <p>Thank you everyone in advance.</p>