Import-Module embed in EXE?

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 7 years and 2 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
4100260298
Posts: 5
Last visit: Fri Aug 03, 2018 9:37 am

Import-Module embed in EXE?

Post by 4100260298 »

Product, version and build: Powershell Studio 2017 (Sapien Studio 2017) 5.4.134
(*** Please do not write "latest" as a version, specify a version number ***)
32 or 64 bit version of product: 64
Operating system:
32 or 64 bit OS: 64 Server 2012R2
PowerShell Version: PSv3 for backward compatibility

I have a need to run a program on servers. The program can run on one of several dozen servers, and I have no visibility or control over those servers. Unfortunately, the script I'm running makes changes to active directory objects, so it needs the activedirectory module to be loaded. So at the beginning of the script, I have import-module activedirectory. The problem is, that module is not installed on the servers that this needs to run on.

So my question is, is there a way to embed the modules that a script needs in the EXE when you build it? Or can I save it as a file, and load it from disk when the script runs?
DevinL
Posts: 1098
Last visit: Tue Jun 06, 2017 9:15 am

Re: Import-Module embed in EXE?

Post by DevinL »

There isn't a way to embed the modules in the exe however you can do something like this with an MSI where you use the staging folder to ensure the module is included in the install directory and then copy the files to the default module install location.

This topic might provide some more information: viewtopic.php?f=12&t=11011
DevinL
SAPIEN Technologies, Inc.
This topic is 7 years and 2 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.