SOLVED

Import-Module dont import any command from my module

%3CLINGO-SUB%20id%3D%22lingo-sub-2046236%22%20slang%3D%22en-US%22%3EImport-Module%20dont%20import%20any%20command%20from%20my%20module%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2046236%22%20slang%3D%22en-US%22%3E%3CP%3EHi%2C%3C%2FP%3E%3CP%3EI%20wrote%20a%20PSmodule%20foo.psm1%2C%20foo.psd1%2C%3C%2FP%3E%3CP%3Ethe%20.PSM1%20contain%20some%20function%20used.%3C%2FP%3E%3CP%3Ethe%20PSD1%20Config%20are%20shown%20below%2C%20the%20problem%20is%20when%20I%20run%20import-module%20foo%2C%20non%20of%20the%20function%20being%20imported%20and%20no%20command%20is%20available%2C%20the%20import%20was%20success%2C%20but%20commands%20are%20not%20available%2C%20I%20notice%20that%20the%20import-module%20-verbose%20is%20importing%20the%20.psd1%20file%20not%20the%20psm1.%3C%2FP%3E%3CP%3EDid%20I%20miss%20anything.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20PSD1%20contents%20are%3C%2FP%3E%3CP%3E%3CEM%3E%23%3C%2FEM%3E%3CBR%20%2F%3E%3CEM%3E%23%20Module%20manifest%20for%20module%20'foo'%3C%2FEM%3E%3CBR%20%2F%3E%3CEM%3E%23%3C%2FEM%3E%3CBR%20%2F%3E%3CEM%3E%23%20Generated%20by%3A%20Stinue%20Nizo%3C%2FEM%3E%3CBR%20%2F%3E%3CEM%3E%23%3C%2FEM%3E%3CBR%20%2F%3E%3CEM%3E%23%20Generated%20on%3A%208%2F1%2F2021%3C%2FEM%3E%3CBR%20%2F%3E%3CEM%3E%23%3C%2FEM%3E%3C%2FP%3E%3CP%3E%3CEM%3E%40%7B%3C%2FEM%3E%3C%2FP%3E%3CP%3E%3CEM%3E%23%20Script%20module%20or%20binary%20module%20file%20associated%20with%20this%20manifest.%3C%2FEM%3E%3CBR%20%2F%3E%3CEM%3E%23%20RootModule%20%3D%20'foo.psm1'%3C%2FEM%3E%3C%2FP%3E%3CP%3E%3CEM%3E%23%20Version%20number%20of%20this%20module.%3C%2FEM%3E%3CBR%20%2F%3E%3CEM%3EModuleVersion%20%3D%20'1.0.1'%3C%2FEM%3E%3C%2FP%3E%3CP%3E%3CEM%3E%23%20ID%20used%20to%20uniquely%20identify%20this%20module%3C%2FEM%3E%3CBR%20%2F%3E%3CEM%3EGUID%20%3D%20'ecdefb1a-d0ee-469d-a48f-bec9b10b38cb'%3C%2FEM%3E%3C%2FP%3E%3CP%3E%3CEM%3E%23%20Author%20of%20this%20module%3C%2FEM%3E%3CBR%20%2F%3E%3CEM%3EAuthor%20%3D%20'Stinue%20Nizo'%3C%2FEM%3E%3C%2FP%3E%3CP%3E%3CEM%3E%23%20Company%20or%20vendor%20of%20this%20module%3C%2FEM%3E%3CBR%20%2F%3E%3CEM%3ECompanyName%20%3D%20'Stinue%20Nizo'%3C%2FEM%3E%3C%2FP%3E%3CP%3E%3CEM%3E%23%20Copyright%20statement%20for%20this%20module%3C%2FEM%3E%3CBR%20%2F%3E%3CEM%3ECopyright%20%3D%20'2021'%3C%2FEM%3E%3C%2FP%3E%3CP%3E%3CEM%3E%23%20Description%20of%20the%20functionality%20provided%20by%20this%20module%3C%2FEM%3E%3CBR%20%2F%3E%3CEM%3EDescription%20%3D%20'Testing%20module'%3C%2FEM%3E%3C%2FP%3E%3CP%3E%3CEM%3E%23%20Minimum%20version%20of%20the%20Windows%20PowerShell%20engine%20required%20by%20this%20module%3C%2FEM%3E%3CBR%20%2F%3E%3CEM%3EPowerShellVersion%20%3D%20'5.1'%3C%2FEM%3E%3C%2FP%3E%3CP%3E%3CEM%3E%23%20Functions%20to%20export%20from%20this%20module%2C%20for%20best%20performance%2C%20do%20not%20use%20wildcards%20and%20do%20not%20delete%20the%20entry%2C%20use%20an%20empty%20array%20if%20there%20are%20no%20functions%20to%20export.%3C%2FEM%3E%3CBR%20%2F%3E%3CEM%3EFunctionsToExport%20%3D%20%40(%22Get-foo%2CTest-foo%2CSet-foo%22)%3C%2FEM%3E%3C%2FP%3E%3CP%3E%3CEM%3E%23%20Cmdlets%20to%20export%20from%20this%20module%2C%20for%20best%20performance%2C%20do%20not%20use%20wildcards%20and%20do%20not%20delete%20the%20entry%2C%20use%20an%20empty%20array%20if%20there%20are%20no%20cmdlets%20to%20export.%3C%2FEM%3E%3CBR%20%2F%3E%3CEM%3ECmdletsToExport%20%3D%20%40()%3C%2FEM%3E%3C%2FP%3E%3CP%3E%3CEM%3E%23%20Variables%20to%20export%20from%20this%20module%3C%2FEM%3E%3CBR%20%2F%3E%3CEM%3EVariablesToExport%20%3D%20'*'%3C%2FEM%3E%3C%2FP%3E%3CP%3E%3CEM%3E%7D%3C%2FEM%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2046236%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EPowerShell%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EWindowsPowershell%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2051824%22%20slang%3D%22en-US%22%3ERe%3A%20Import-Module%20dont%20import%20any%20command%20from%20my%20module%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2051824%22%20slang%3D%22en-US%22%3E%3CP%3EHello%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F819940%22%20target%3D%22_blank%22%3E%40niazstinu%3C%2FA%3E%2C%3C%2FP%3E%3CP%3EYou%20did%20not%20specify%20Root%20module.%20Your%20line%20with%20%3CSTRONG%3ERootModule%20%3D%20'foo.psm1%3C%2FSTRONG%3E'%20is%20commented.%3C%2FP%3E%3CP%3EHope%20that%20helps.%3C%2FP%3E%3C%2FLINGO-BODY%3E
Contributor

Hi,

I wrote a PSmodule foo.psm1, foo.psd1,

the .PSM1 contain some function used.

the PSD1 Config are shown below, the problem is when I run import-module foo, non of the function being imported and no command is available, the import was success, but commands are not available, I notice that the import-module -verbose is importing the .psd1 file not the psm1.

Did I miss anything.

 

The PSD1 contents are

#
# Module manifest for module 'foo'
#
# Generated by: Stinue Nizo
#
# Generated on: 8/1/2021
#

@{

# Script module or binary module file associated with this manifest.
# RootModule = 'foo.psm1'

# Version number of this module.
ModuleVersion = '1.0.1'

# ID used to uniquely identify this module
GUID = 'ecdefb1a-d0ee-469d-a48f-bec9b10b38cb'

# Author of this module
Author = 'Stinue Nizo'

# Company or vendor of this module
CompanyName = 'Stinue Nizo'

# Copyright statement for this module
Copyright = '2021'

# Description of the functionality provided by this module
Description = 'Testing module'

# Minimum version of the Windows PowerShell engine required by this module
PowerShellVersion = '5.1'

# Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export.
FunctionsToExport = @("Get-foo,Test-foo,Set-foo")

# Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export.
CmdletsToExport = @()

# Variables to export from this module
VariablesToExport = '*'

}

 

 

2 Replies
best response confirmed by niazstinu (Contributor)
Solution

Hello @niazstinu,

You did not specify Root module. Your line with RootModule = 'foo.psm1' is commented.

Hope that helps.

@AndySvints 

AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA

I read the PSD1 line by line and I dont know how I miss this

not good to code for more than 24 hour :)

 

Thanks