0
votes

Powershell is really testing my patience today... Ok, so I made a manifest to get my required assemblies. Now how do I properly import when I have a *.psm1 and *.psd1 file.

folder path: C:\mypath\blah\blah\Module\Format-XML\

files in folder: Format-XML.psd1, Format-XML.psm1

Import-Module -Name "C:\mypath\blah\blah\Module\Format-XML\Format-XML"

Then when I got to use my function in my module called from another script, for whatever reason, doesn't exist/work. What am I doing wrong?

[ERROR] VERB-NOUN: The term 'VERB-NOUN' is not recognized as the name of a

[ERROR] cmdlet, function, script file, or operable program. Check the spelling of the

[ERROR] name, or if a path was included, verify that the path is correct and try again.

In the *.psd1:

FunctionsToExport = '*'

In the *.psm1:

#I know... not required but I tried anyways... :(
Export-ModuleMember -Function '*'
3

3 Answers

3
votes

So exactly following code need to be added to your psd1.

# Script module or binary module file associated with this manifest.
RootModule = 'nameOfYourModule.psm1'
0
votes

Have a look at the module that's imported. You can do this this 2 ways:

After import:

$mod = Get-Module -Name Format-XML

During import:

$mod = Import-Module -Name "C:\mypath\blah\blah\Module\Format-XML\Format-XML" -PassThru

Then you can check $mod and look at the .ExportedCommands property. Is anything listed?

Also try removing the second Format-XML (I'm assuming that last component refers to the module itself and not the folder).

0
votes

Answer: Don't forget to set your root module in the manifest... sigh