Successfully imported module listed in Get-Module but not running

Welcome Forums General PowerShell Q&A Successfully imported module listed in Get-Module but not running

This topic contains 3 replies, has 3 voices, and was last updated by

1 year, 3 months ago.

  • Author
  • #83614

    Points: 1
    Rank: Member

    I have now successfully converted my script to a module(.psm1), it loads, but immediately gives this error! What am I doing wrong please?

    PS 337 D:\Scripts> import-module -name d:\scripts\modules\modem\modem.psm1 -global -force
    Calculating total connect time of all GPRS modem devices...
    Total online usage since 30/10/2017 is 00:22:00 minutes (5 Mb)
    PS 338 D:\Scripts> modem
    modem : The term 'modem' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the
    spelling of the name, or if a path was included, verify that the path is correct and try again.
    At line:1 char:1
    + modem
    + ~~~~~
        + CategoryInfo          : ObjectNotFound: (modem:String) [], CommandNotFoundException
        + FullyQualifiedErrorId : CommandNotFoundException
    PS 339 D:\Scripts> get-module -name modem
    ModuleType Version    Name     ExportedCommands
    ---------- -------    ----     ----------------
    Script     0.0        modem    {AddTime, convert, SubtractTime}
  • #83617

    Points: 0
    Rank: Member

    You have to pass through till here d:\scripts\modules\modem they try it. You are trying from Scripts folder only. you have to pass modules and modem.

  • #83621

    Points: 1
    Rank: Member

    I also omitted to wrap the whole script code with

    function Get-Modem { #complete existing code }

    . Never done this before so I will try again.

  • #83669

    Points: 1
    Rank: Member

    The purpose of a module is to group functions. When you import your module named 'modem' that makes the functions within it available. Unless you have a function named 'modem' within your module named 'modem' you should get that error. Try running this command to see the available functions in your module then go from there.

    get-command -module modem

The topic ‘Successfully imported module listed in Get-Module but not running’ is closed to new replies.

denizli escort samsun escort muğla escort ataşehir escort kuşadası escort