psm1 file not recognized by Import-Module

This topic contains 2 replies, has 2 voices, and was last updated by Profile photo of Salam Elias Salam Elias 1 year, 10 months ago.

  • Author
    Posts
  • #25628
    Profile photo of Salam Elias
    Salam Elias
    Participant

    Hi, I started to experiment the modules in powershell, created a very basic Greetings.psm1 one and placed it in

    [blockquote]C:\Users\myuser.domain\Documents\WindowsPowerShell\Modules
    [/blockquote]
    I double checked my $env:psmodulepath, it contains 4 paths, one of them the one mentioned above.
    [blockquote]C:\Users\myuser.domain\Documents\WindowsPowerShell\Modules\
    C:\Program Files\WindowsPowerShell\Modules
    C:\Windows\system32\WindowsPowerShell\v1.0\Modules\
    C:\Program Files [x86]\Microsoft SQL Server\120\Tools\PowerShell\Modules\
    [/blockquote]
    Doing a

    Get-Module -ListAvailable
    PS lists all modules in the 3rd and 4rth directories but not the psm1 found in my user powershell directory Is there any specific config needs to be done in order to make the module available apart from dropping it in one of the directories (I even dropped it in C:\Windows\system32\WindowsPowerShell\v1.0\Modules\ it did not show neither

    Thanks for your help

  • #25629
    Profile photo of Don Jones
    Don Jones
    Keymaster

    The .psm1 can't go into the \Modules folder. You need to create a subfolder.

    ...\Modules\MyModule\MyModule.psm1

    The subfolder name and .psm1 filename (e.g., "MyModule") must match.

  • #25631
    Profile photo of Salam Elias
    Salam Elias
    Participant

    Thanks Don, absolutly correct, it is working now

You must be logged in to reply to this topic.