title: Variables in modules in PowerShell
body: <p>I have a main script, where a few constants are defined. I then have a module (psm1) to include helper functions. The details are:</p>
  
  <p>In the main script, I have imported the module as an object:</p>
  
  <pre><code>$cud2ADhleper = Import-Module -Force $cud2ADhelperModule -AsCustomObject
  </code></pre>
  
  <p>In the module, I have two variables,</p>
  
  <pre><code>[string]$SQLServer = $null
  
  Function SetSQLServerAddr ([string] $name)
  {
      $SQLServer = $name
  }
  Function GetSQLServerAddr
  {
      return $SQLServer
  }
  </code></pre>
  
  <p>My understanding is that because I am not exporting <code>$SQLServer</code> from the module, this variable should be local, and I should be able to Set/Get it.</p>
  
  <p>It turns out otherwise. After I called <code>SetSQLServerAddr ([string] $name)</code>, then callling <code>GetSQLServerAddr</code> returns $null. What did I miss?</p>