powershellmodulepowershell-cmdletpowershell-modulepowershellget

Powershell not importing functions from module


I'm trying to setup a NuGet Feed here, and that worked ok. I installed a module from my feed via

Install-Module -Name MyCmdlets -Repository $RepoName -Scope CurrentUser -Force
Import-Module -Name MyCmdlets

However when I run Get-Module, I get no functions and it's a manifest?

ModuleType Version    Name                                ExportedCommands                                  
---------- -------    ----                                ----------------                                  
Manifest   1.0        MyCmdlets          

If I manually go to the installed location and import manually

Import-Module <my-path>\1.0\MyCmdlets.psm1                 

ModuleType Version    Name                                ExportedCommands                                  
---------- -------    ----                                ----------------                     
Script     0.0        MyCmdlets                      {Create-Project, Get-AuditLogs, Get-..             

My manifest file does have these lines so I don't understand why Import-Module isn't working correctly.

FunctionsToExport = '*'

CmdletsToExport = '*'


Solution

  • I guess you haven't set the root module in your .psd1 like so

    #
    # Module manifest for module 'YourModule'
    #
    
    @{
    
    # Script module or binary module file associated with this manifest
    RootModule = 'YourModule.psm1'
    
    # Version number of this module.
    ModuleVersion = '1.0.0'
    
    ...
    

    This is necessary so that when you import your manifest module it also loads the script module