title: Variable Scopes Within PowerShell Nested Functions
body: <p>I was given this extensive PowerShell script from a major/reputable corporation which was supposed to work flawlessly. Well, it didn't.<br>
  The script is composed of numerous nested functions with lots of variables passed to the main parent function and then to all of its children. Children who use and modify all these variables. </p>
  
  <p>Why is it that all these variables do not contain the correct data?<br>
  Here's the structure I'm talking about:</p>
  
  
  
  <pre class="lang-powershell prettyprint-override"><code>f1 {
       f2 {
            v #prints 0
            v = 1
            f3
       }
       f3 {
            v #prints 1
            v = 2
       }
       v = 0
       f2
       v #should print 2 but prints 0
  }
  </code></pre>