I need to package a PS script as an EXE.  The script calls the ActiveDirectory Module.
Works fine as a script.  Every time.  But when I package it and execute it I get:

Maybe I'm wrong, but my only explanation for that is that the ActiveDirectory Module must not be loading.  So I tried specifically launching PS with Arguments -noexit -command import-module ActiveDirectory but no luck.  Tried putting the Arguments in quotes but no luck there either.

Any help here would be much appreciated!

1 Comment   [ - ] Hide Comment


  • This is not related to just that command.. it appears that the packaged powershell command is missing several modules.. seems to be may be only a V2 module... not sure. invoke-webrequest is missing as well. Same thing.. if I do not hide the console it works.
Please log in to comment

Answer this question or Comment on this question for clarity


I've found the apparent cause of the issue... hiding the Console.
It appears that Modules will not Import without a visible Console.  My solution was to Import the Module, then hide the Console.

If anybody has any further information or solutions for this, I'd still love to know.

Answered 10/08/2015 by: talessi
White Belt

Please log in to comment
Admin Script Editor
Admin Script Editor is an integrated scripting environment available free here at ITNinja