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

Ask your Windows 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.
Locked
User avatar
kerbob
Posts: 25
Joined: Sun Mar 03, 2013 12:39 pm

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

Post by kerbob » Wed Aug 10, 2016 9:35 pm

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: 7055
Joined: Tue May 29, 2007 4:43 pm

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

Post by Alexander Riedel » Thu Aug 11, 2016 12:42 am

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
Joined: Wed Oct 08, 2014 6:02 am

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

Post by dan.potter » Thu Aug 11, 2016 1:31 am

c) pop up a warning telling user that the ad module is required.

User avatar
kerbob
Posts: 25
Joined: Sun Mar 03, 2013 12:39 pm

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

Post by kerbob » Thu Aug 11, 2016 7:24 am

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.

Locked