Page 1 of 1

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

Posted: Wed Aug 10, 2016 9:35 pm
by kerbob
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.

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

Posted: Thu Aug 11, 2016 12:42 am
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.

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

Posted: Thu Aug 11, 2016 1:31 am
by dan.potter
c) pop up a warning telling user that the ad module is required.

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

Posted: Thu Aug 11, 2016 7:24 am
by kerbob
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.