user1869558
user1869558

Reputation: 705

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 = '*'

Upvotes: 7

Views: 4845

Answers (2)

James Arber
James Arber

Reputation: 11

For anyone coming across this looking for why their module wont import check that RootModule = 'YourModule.psm1' isn't commented out. By default when creating a new manifest using New-ModuleManifest it throws a hash in front of this line..

ugh I feel so stupid.

Upvotes: 0

DAXaholic
DAXaholic

Reputation: 35408

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

Upvotes: 10

Related Questions