Will exe compiled scripts that use ActiveDirectory module run on systems that do not have it installed?

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 7 years and 7 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
jpbobrek
Posts: 25
Last visit: Sat Dec 23, 2023 1:52 pm

Will exe compiled scripts that use ActiveDirectory module run on systems that do not have it installed?

Post by jpbobrek »

All of my systems have the AD module installed, but I'm trying to write a script that will execute on new Win7/Win8/Win10 systems (without the AD module installed). Will a script compiled with Powershell Studio 2016 that uses the ad module run on systems that do not have it?
I'm guessing it will not, but hoping that it will.
User avatar
Alexander Riedel
Posts: 8478
Last visit: Tue Mar 26, 2024 8:52 am
Answers: 19
Been upvoted: 37 times

Re: Will exe compiled scripts that use ActiveDirectory module run on systems that do not have it installed?

Post by Alexander Riedel »

No, of course that won't work. Where would the missing module come from?
You have two options here that I can see:
a) Package your script with the required modules into an MSI, install on new machines and run it.
b) Detect that import-module failed, install the module from the LAN and continue execution in your script after the module loaded successfully.
Alexander Riedel
SAPIEN Technologies, Inc.
User avatar
dan.potter
Posts: 709
Last visit: Wed Nov 14, 2018 11:39 am

Re: Will exe compiled scripts that use ActiveDirectory module run on systems that do not have it installed?

Post by dan.potter »

c) pop up a warning telling user that the ad module is required.
User avatar
jpbobrek
Posts: 25
Last visit: Sat Dec 23, 2023 1:52 pm

Re: Will exe compiled scripts that use ActiveDirectory module run on systems that do not have it installed?

Post by jpbobrek »

Thanks. I'm used to the old perl2exe. Any functions of modules you used were included in the exe so they could be run anywhere.

I ended up pulling the user attributes in a way that doesn't use the ad module.
new-object System.DirectoryServices.DirectorySearcher($dn)

Thanks.. still lots to learn.
This topic is 7 years and 7 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