Importing PS Module into Project

Ask your PowerShell-related questions, including questions on cmdlet development!
Forum rules
Do not post any licensing information in this forum.

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 6 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.
Locked
User avatar
Jzzocco86
Posts: 8
Last visit: Tue Jan 30, 2024 12:34 pm

Importing PS Module into Project

Post by Jzzocco86 »

Good Morning,

I am currently working on a utility script and someone has written a PowerShell Module that includes several functions that I want to take advantage of in my utility.

I have added the .psm1 and .psd1 files into the project folder and added them as "existing" files in the project.

I have also imported the module into the cache and rebuilt the cache.

However, I am unable to change the Build and Shared properties on the file.

I would like to be able to package the module alongside the script so that I dont have to provide the module to other users.

What is the correct procedure for including powershell modules into a forms project?
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Importing PS Module into Project

Post by jvierra »

Why would you include a third party module into a project? Just distribute the module with your installer. It should not be part of the project.
User avatar
Jzzocco86
Posts: 8
Last visit: Tue Jan 30, 2024 12:34 pm

Re: Importing PS Module into Project

Post by Jzzocco86 »

jvierra,

Thanks for the reply. I was hoping to package this into an EXE not an MSI.

Looks like my only choice is to either import the functions from the 3rd party module or create an MSI.

Thanks again for the help.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Importing PS Module into Project

Post by jvierra »

You can add the module folder to the project as an external folder and then explicitly import it using the path.

Import-Module $PsScriptRoot\TheModule

You would have to copy the folder and the exe to the target. You can also place all of this on a share and allow users to run it from the share.
This topic is 6 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.
Locked