Custom Module Not Loading

This forum can be browsed by the general public. Posting is limited to current SAPIEN license holders with active maintenance and does not offer a response time guarantee.
Forum rules
DO NOT POST LICENSE NUMBERS, ACTIVATION KEYS OR ANY OTHER LICENSING INFORMATION IN THIS FORUM.
Only the original author and our tech personnel can reply to a topic that is created in this forum. If you find a topic that relates to an issue you are having, please create a new topic and reference the other in your post.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 5 years and 3 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
PS_Systems
Posts: 2
Last visit: Thu Dec 13, 2018 9:43 am

Custom Module Not Loading

Post by PS_Systems »

Product, version and build: PowerShell Studio 2019
32 or 64 bit version of product: 64
Operating system: Windows Server 2016
32 or 64 bit OS: 64

Greetings programs :)

I have a project with a _Modules sub folder. I have added functions to a custom module in that folder (myFunctions.psm1). I am running Export-ModuleMember -Function Load-ComboBox, Update-ComboBox. I have set the 'Shared' value on the custom module to True.

I have a form, located in another sub folder _Froms (Home.psf). I can successfully reference the Load-ComboBox function, blue text with intellisence. When I run the project I get the 'The term 'Load-ComboBox' is not recognized as the name of a cmdlet, function, script file, or operable program.'

I am obviously missing some reference, somewhere. I just started using PSStudio and am unfamiliar with the proper way to reference and load custom modules.

Any assistance would be appreciated. Thanks!
User avatar
davidc
Posts: 5913
Last visit: Mon Jul 08, 2019 8:55 am
Been upvoted: 2 times

Re: Custom Module Not Loading

Post by davidc »

If you have a psm1 in with Build is set to Content and Shared = True, your script must still load psm1 file during execution in order for PowerShell to discover the functions.

Is there a reason you are using a psm1 instead of just using ps1 that are built as part of the project? If you set the Build property to Include, PowerShell Studio will merge the file into the final script.
David
SAPIEN Technologies, Inc.
This topic is 5 years and 3 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.