How to make PowerShell Studio import custom modules?

Use this forum to ask questions after your subscription maintenance expires or before you buy. Need information on licensing or pricing? Questions about a trial version? This is the right place for you. No scripting questions, please.
Forum rules
DO NOT POST SUBSCRIPTION NUMBERS, LICENSE 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.
This topic is 6 years and 9 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.
User avatar
amloessb
Posts: 10
Last visit: Wed Nov 18, 2020 11:45 am

How to make PowerShell Studio import custom modules?

Post by amloessb »

Product, version and build: PowerShell Studio 2017 (5.4.140.0)
32 or 64 bit version of product: 64-bit
Operating system: Windows 8.1
32 or 64 bit OS: 64-bit

I'm trying to get PowerShell Studio to load some custom modules (.psm1) that I use in a lot of my scripts, so that PrimalSense will be aware of the functions/parameters/etc.

I have done the following in order to attempt to make this happen. (Still can't post images; copy and paste the links to view them.)
  1. Home > Platform > Edit Cache
    https://i.imgur.com/nFrQlCu.png
  2. Import my module, make sure it appears and is checked in the list, build the cache
    https://i.imgur.com/qJ6Nzzo.png
But the functions I have defined there are still showing up as unknown:
https://i.imgur.com/icm2p5I.png
How do I make PowerShell Studio aware of custom module files that I have written?

Thanks.
User avatar
Alexander Riedel
Posts: 8479
Last visit: Thu Mar 28, 2024 9:29 am
Answers: 19
Been upvoted: 37 times

Re: How to make PowerShell Studio import custom modules?

Post by Alexander Riedel »

If you updated your module without increasing the version number it will not be re-imported because it thinks it is already cached.
So either delete the module first and then import it again or increase the version number when you make changes to your module.
Alexander Riedel
SAPIEN Technologies, Inc.
User avatar
amloessb
Posts: 10
Last visit: Wed Nov 18, 2020 11:45 am

Re: How to make PowerShell Studio import custom modules?

Post by amloessb »

This is the first time I have ever tried to import the module, and none of its functions are recognized by PrimalSense, so the version number is irrelevant.
User avatar
Alexander Riedel
Posts: 8479
Last visit: Thu Mar 28, 2024 9:29 am
Answers: 19
Been upvoted: 37 times

Re: How to make PowerShell Studio import custom modules?

Post by Alexander Riedel »

In that case please provide some more information about your module. Is it exporting functions? Classes?
Are none of the functions in your module visible? Can you see the module and its functions in the Object browser?
Alexander Riedel
SAPIEN Technologies, Inc.
User avatar
amloessb
Posts: 10
Last visit: Wed Nov 18, 2020 11:45 am

Re: How to make PowerShell Studio import custom modules?

Post by amloessb »

Functions only. One of the functions uses a class via Add-Type as part of its execution, but there are none other than that.

I can see the module itself in the object browser, but clicking the arrowhead to expand it does nothing:
https://i.imgur.com/bCslPDH.png
The normal way that I use this module in my scripts is to just run
Import-Module Path\to\Common-Commands.psm1
User avatar
Alexander Riedel
Posts: 8479
Last visit: Thu Mar 28, 2024 9:29 am
Answers: 19
Been upvoted: 37 times

Re: How to make PowerShell Studio import custom modules?

Post by Alexander Riedel »

Is it possible for you to send us this module for evaluation?
Alexander Riedel
SAPIEN Technologies, Inc.
User avatar
amloessb
Posts: 10
Last visit: Wed Nov 18, 2020 11:45 am

Re: How to make PowerShell Studio import custom modules?

Post by amloessb »

I can't send you that specific module since it contains proprietary code that I can't share, but I can provide a second module that is exhibiting the same behavior. What would be the best way for me to do so?
User avatar
Alexander Riedel
Posts: 8479
Last visit: Thu Mar 28, 2024 9:29 am
Answers: 19
Been upvoted: 37 times

Re: How to make PowerShell Studio import custom modules?

Post by Alexander Riedel »

Please upload it here and reference this thread: https://www.sapien.com/support/upload
Alexander Riedel
SAPIEN Technologies, Inc.
User avatar
amloessb
Posts: 10
Last visit: Wed Nov 18, 2020 11:45 am

Re: How to make PowerShell Studio import custom modules?

Post by amloessb »

Uploaded. Thanks.
User avatar
Alexander Riedel
Posts: 8479
Last visit: Thu Mar 28, 2024 9:29 am
Answers: 19
Been upvoted: 37 times

Re: How to make PowerShell Studio import custom modules?

Post by Alexander Riedel »

There is no manifest with this module?
Alexander Riedel
SAPIEN Technologies, Inc.
This topic is 6 years and 9 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.