title: Powershell v1: Is it possible to assign the result of a switch statement to a variable?
body: <p>Is it possible to assign the result of a switch statement to a variable.</p>
  
  <p>For example, instead of:</p>
  
  <pre><code>switch ($Extension) 
      { 
          doc {$Location = "C:\Users\username\Documents\"; break} 
          exe {$Location = "C:\Users\username\Downloads\"; break}
          default {$Location = "C:\Users\username\Desktop\"}
      }
  </code></pre>
  
  <p>Is it possible to do something similar to:</p>
  
  <pre><code>$Location = 
  {
      switch ($Extension) 
      { 
          doc {"C:\Users\username\Documents\"; break} 
          exe {"C:\Users\username\Downloads\"; break}
          default {"C:\Users\username\Desktop\"}
      }
  }
  </code></pre>
  
  <p>Trying the above results in $location containing the entire code block as a String.</p>