title: Import PowerShell module from within some subfolders
body: <p>Although there are already plenty of questions and blogs regarding PowerShell module imports, I did not found any that would answer my question.</p>
  <p>I'm trying to import modules which are grouped within subfolders without adding all those subfolders to the <code>$env:PSModulePath</code>. Example of the folder structure:</p>
  <pre><code>...\WindowsPowerShell\Modules\
  ...\WindowsPowerShell\Modules\Avengers
  ...\WindowsPowerShell\Modules\Avengers\ModuleHulk\ModuleHulk.psd1
  ...\WindowsPowerShell\Modules\Avengers\ModuleThor\ModuleThor.psd1
  ...\WindowsPowerShell\Modules\X-Men
  ...\WindowsPowerShell\Modules\X-Men\ModuleProfX\ModuleProfX.psd1
  ...\WindowsPowerShell\Modules\X-Men\ModuleMagneto\ModuleMagneto.psd1
  ...\WindowsPowerShell\Modules\FantasticFour
  ...\WindowsPowerShell\Modules\FantasticFour\ModuleMisterFantastic\ModuleMisterFantastic.psd1
  ...\WindowsPowerShell\Modules\FantasticFour\ModuleInvisibleWoman\ModuleInvisibleWoman.psd1
  </code></pre>
  <p>According to the Microsoft Docs the module .psd1 filename has to be the same as the module folder name. This is satisfied above. The modules have to be within a location of the <code>$env:PSModulePath</code>, all good.</p>
  <p>Unfortunately, PowerShell fails to import these modules:</p>
  <pre><code>PS&gt; Import-Module ModuleHulk
  Import-Module : The specified module 'ModuleHulk' was not loaded because no valid module file was found in any module directory.
  At line:1 char:1
  + Import-Module ModuleHulk
  + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      + CategoryInfo          : ResourceUnavailable: (ModuleHulk:String) [Import-Module], FileNotFoundException
      + FullyQualifiedErrorId : Modules_ModuleNotFound,Microsoft.PowerShell.Commands.ImportModuleCommand
  
  PS&gt;
  </code></pre>
  <p>However, recently I found out one can also import modules using the fairly new <code>using module</code> statement (since PowerShell Version 5). For doing that I could add the following code at the very beginning in my scripts or execute that even in the console:</p>
  <pre><code>#Requires -Version 5
  using module ModuleHulk
  </code></pre>
  <pre><code>PS&gt; using module ModuleHulk
  PS&gt;
  </code></pre>
  <p>No issue, all good, so the module itself is fine and can be imported as usual. But, this seems to be a hacky solution and it needs at least PowerShell 5. Now the question:</p>
  <p>Is there any way to achieve that using the usual <code>Import-Module</code> cmdlet, without adding all the subfolders to the <code>$env:PSModulePath</code>?</p>