Problems importing modules

This topic contains 2 replies, has 2 voices, and was last updated by Profile photo of Paul Shamus Paul Shamus 6 months, 2 weeks ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #36673
    Profile photo of Paul Shamus
    Paul Shamus
    Participant

    I have a series of modules (41) that are designed to work together but can be imported separately if needed. When the modules are installed in C:\Program Files\WindowsPowerShell\Modules\, it imports with no issue. At this point, we have a simple script that copies all of the modules directly into C:\Program Files\WindowsPowerShell\Modules, and all works well.

    However, I would like to be able to use PowerShellGet to create a module package that contains all of the modules together and be able to distribute them as a whole, since they are versioned that way. Ideally the modules would be part of a single parent module that would be the basis for the PowerShellGet package. I attempted to publish a parent module with a manifest, empty root (PSM1) module, and all of my other modules contained in the parent module folder. After publishing to an internal SMB repository, the module installs fine, I am able to see them when I run Get-Module -ListAvailable, however they are unable to be imported the normal way (Import-Module ). For some reason, doing Get-Module -ListAvailable | Import-Module DOES work. What is going on here? What am I missing?

    Sorry to be so long-winded and potentially confusing. I am thoroughly confused myself. 😉

    #36678
    Profile photo of Henry Buckle
    Henry Buckle
    Participant

    In the module manifest for the parent you can specify all the child modules in the NestedModules tag and they should all be imported automatically when the parent is imported.

    #36727
    Profile photo of Paul Shamus
    Paul Shamus
    Participant

    Thanks for the reply. The problem with that is many of the nested modules can be used on it's own, so I'd prefer not to load all 41 modules (around 55k lines of PowerShell code) into memory while running an automation that may only require two or three of the modules. The parent module would purely be for packaging and easy installation via PowerShellGet.

    I'm just confused as to why

    Import-Module [ModuleName]

    doesn't work but

    Get-Module [ModuleName] -ListAvailable | Import-Module

    does work.

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.