title: How to modify parent scope variable using Powershell
body: <p>I'm fairly new to powershell, and I'm just not getting how to modify a variable in a parent scope:</p>
  
  <pre><code>$val = 0
  function foo()
  {
      $val = 10
  }
  foo
  write "The number is: $val"
  </code></pre>
  
  <p>When I run it I get:</p>
  
  <pre class="lang-none prettyprint-override"><code>The number is: 0
  </code></pre>
  
  <p>I would like it to be 10. But powershell is creating a new variable that hides the one in the parent scope.</p>
  
  <p>I've tried these, with no success (as per the documentation):</p>
  
  <pre><code>$script:$val = 10
  $global:$val = 10
  $script:$val = 10
  </code></pre>
  
  <p>But these don't even 'compile' so to speak.
  What am I missing?</p>