Custom Modules and Object Browser

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 11 years and 4 weeks 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.
User avatar
FarmersDairy
Posts: 22
Last visit: Wed Jul 24, 2019 1:00 pm

Custom Modules and Object Browser

Post by FarmersDairy »

I am having a problem getting my custom modules so that I can use them from the object browser in PowerShell Studio 2012. I have the modules in their own directors in "C:\Users\username\Documents\WindowsPowerShell\Modules", When I press the refresh button in the object browser one of two things happen. Either the module does not appear in the list or it appears, but it is "EMPTY". I have tried this on two different systems with the same results.
User avatar
davidc
Posts: 5913
Last visit: Mon Jul 08, 2019 8:55 am
Been upvoted: 2 times

Re: Custom Modules and Object Browser

Post by davidc »



Usually when it’s empty it means it didn't find an exported function or there is an error that prevents the cache from building. This could happen when the module requires a specific host or has a dependency that can't load.

If this is not the case, please zip and email the problem module to support@sapien.com and we will take a look at it.

David
David
SAPIEN Technologies, Inc.
User avatar
FarmersDairy
Posts: 22
Last visit: Wed Jul 24, 2019 1:00 pm

Re: Custom Modules and Object Browser

Post by FarmersDairy »

Thanks David. I have forwarded the information.
User avatar
davidc
Posts: 5913
Last visit: Mon Jul 08, 2019 8:55 am
Been upvoted: 2 times

Re: Custom Modules and Object Browser

Post by davidc »

Found the problem. In the manifest you need to specify the RootModule:

RootModule = 'AmberLabOS.psm1'

Once you add this line the module commands will show.

David
David
SAPIEN Technologies, Inc.
User avatar
FarmersDairy
Posts: 22
Last visit: Wed Jul 24, 2019 1:00 pm

Re: Custom Modules and Object Browser

Post by FarmersDairy »

Thanks for the response, but no joy. :cry: I added the line (copy & paste) from your post, saved it, restarted PS Studio (to be safe) and then did a refresh in the Object Browser. I am doing this on my work (Windows 8 Pro) system. I will try it at home (Windows 7 Pro) system again, as I have the same problem there.

I will note that when I originally created the module, I used NEW | NEW MODULE PROJECT in PS Studio. I just created a new test module and it does not automatically include a RootModule entry in the generated manifest file. Bug?
User avatar
davidc
Posts: 5913
Last visit: Mon Jul 08, 2019 8:55 am
Been upvoted: 2 times

Re: Custom Modules and Object Browser

Post by davidc »

It is included automatically. I saw that you commented out a few fields in the manifest and it is possible that you removed the entry. A simple test is to create a new module and copy the functions over. To test the module run the following in the console:
PowerShell Code
Double-click the code block to select all.
Import-Module AmberLabOS
Get-Command -Module AmberLabOS

David
David
SAPIEN Technologies, Inc.
User avatar
FarmersDairy
Posts: 22
Last visit: Wed Jul 24, 2019 1:00 pm

Re: Custom Modules and Object Browser

Post by FarmersDairy »

As I said in my last post, I did create a new module. I did exactly as you suggested and copy/pasted the code. I did not touch the manifest file. I got the same result and no "RootModule" line.
User avatar
FarmersDairy
Posts: 22
Last visit: Wed Jul 24, 2019 1:00 pm

Re: Custom Modules and Object Browser

Post by FarmersDairy »

I created another module from scratch and once again I got the same results on my Windows 8 Pro system. I did not get a chance to try it on my Windows 7 Pro system at home. I will try this evening and post the results.
User avatar
FarmersDairy
Posts: 22
Last visit: Wed Jul 24, 2019 1:00 pm

Re: Custom Modules and Object Browser

Post by FarmersDairy »

Dumb, dumb, dumb, DUMB!!! :oops: Execution Policy was set to AllSigned instead of RemoteSigned. It still does not explain why the ROOTMODULE was missing in the manifest, though. It still is not there, but the modules work now and appear in the Object Browser.

Thanks for you help, David. Tough dealing with dumb people is it not? :lol:
User avatar
davidc
Posts: 5913
Last visit: Mon Jul 08, 2019 8:55 am
Been upvoted: 2 times

Re: Custom Modules and Object Browser

Post by davidc »

Sorry it wasn't RootModule, which is what you had commented out in your original psd1 file. It is actually ModuleToProcess.

Either way I’m glad it is finally working.

David
David
SAPIEN Technologies, Inc.
This topic is 11 years and 4 weeks 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.