7

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

2 Answers 2

10

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

Sign up to request clarification or add additional context in comments.

2 Comments

Thank you! Can't believe I missed that. I'll need to review the manifest files more in the future.
I knew that because I did the same a couple of weeks ago :D
0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.