StackExchangeGuy
StackExchangeGuy

Reputation: 789

Exporting PS Members from Module Fails

I have a psm1 module with several functions. I only want to expose some of the functions, so I used "Export-ModuleMember -Function " and everything was fine.

Now I want to add a manifest, so I removed the Export-ModuleMember cmdlet and put the function names under the FunctionsToExport section of the psd1 file.

When I import the module, I can tab-complete the functions, but when I try to use them, ps says:

Test-Function : The term 'Test-Function' 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.

I also tried putting Export-ModuleMember -Function * into the psm1, but that didn't help.

The psm1 and psd1 files are named the same and are in the root of the module.

Thoughts? Thanks.

Upvotes: 1

Views: 109

Answers (2)

StackExchangeGuy
StackExchangeGuy

Reputation: 789

I found the answer. I had forgotten to un-comment the RooteModule node. Once I did that (and had module.psm1 as the value), the exported commands showed up in the "Get-Module module" output.

Upvotes: 1

BartekB
BartekB

Reputation: 8650

I would suspect that PowerShell caching mechanism is involved here. Try to run:

Get-Module -ListAvailable -Refresh

I recommend very good article on that subject written by PowerShell MVP Tobias Weltner.

Upvotes: 0

Related Questions