title: Dot-sourcing functions from file to global scope inside of function
body: <p>I want to import external function from file, not converting it to a module (we have hundreds of file-per-function, so treat all them as modules is overkill).</p>
  
  <p>Here is code explanation. Please notice that I have some additional logic in Import-Function like adding scripts root folder and to check file existence and throw special error, to avoid this code duplication in each script which requires that kind of import.</p>
  
  <p>C:\Repository\Foo.ps1:</p>
  
  <pre><code>Function Foo {
      Write-Host 'Hello world!'
  }
  </code></pre>
  
  <p>C:\InvocationTest.ps1:</p>
  
  <pre><code># Wrapper func
  Function Import-Function ($Name) {
      # Checks and exception throwing are omitted
      . "C:\Repository\$name.ps1"
  
      # Foo function can be invoked in this scope
  }
  
  # Wrapped import
  Import-Function -Name 'Foo'
  Foo          # Exception: The term 'Foo' is not recognized
  
  # Direct import
  . "C:\Repository\Foo.ps1"
  Foo          # 'Hello world!'
  </code></pre>
  
  <p>Is there any trick, to dot source to global scope?</p>