Module not loaded from file included in $env:PSModulePath RRS feed

  • Question

  • PowerShell can only find the module if I specify the whole path:

    PS D:\it\ps1> $env:PSModulePath

    D:\My Documents\WindowsPowerShell\Modules;C:\Program Files\WindowsPowerShell\Modules;C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules\;C:\Program Files (x86)\Microsoft SQL Server\110\Tools\PowerShell\Modules\

    PS D:\it\ps1> $file = "D:\My Documents\WindowsPowerShell\Modules"

    PS D:\it\ps1> dir $file

        Directory: D:\My Documents\WindowsPowerShell\Modules

    Mode                LastWriteTime     Length Name                                                                                              

    ----                -------------     ------ ----                                                                                               

    -a---        05-07-2015     19:29        628 CurrencyConversion.psm1                                                                           

    -a---        05-07-2015     20:55      42923 PSFTP.psm1                                                                                         


    PS D:\it\ps1> Import-Module CurrencyConversion -PassThru

    Import-Module : The specified module 'CurrencyConversion' was not loaded because no valid module file was found in any module directory.

    At line:1 char:1

    + Import-Module CurrencyConversion -PassThru

    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

        + CategoryInfo          : ResourceUnavailable: (CurrencyConversion:String) [Import-Module], FileNotFoundException

        + FullyQualifiedErrorId : Modules_ModuleNotFound,Microsoft.PowerShell.Commands.ImportModuleCommand


    PS D:\it\ps1> $File2 = $File + "\CurrencyConversion"

    PS D:\it\ps1> Import-Module $File2

    PS D:\it\ps1> Get-Command -Module CurrencyConversion

    CommandType     Name                                               ModuleName                                                                  

    -----------     ----                                               ----------                                                                   

    Function        ConvertTo-DKKEuro                                  CurrencyConversion                                                          

    Function        ConvertTo-EuroDKK                                  CurrencyConversion   

    PS D:\it\ps1> 




    Wednesday, July 8, 2015 11:41 AM


  • It is not in a folder of the same name it is just in the modules folder.  Modules are discovered by folder name.


    • Marked as answer by janand3050 Thursday, July 9, 2015 5:23 PM
    Wednesday, July 8, 2015 2:17 PM

All replies