05/22/2018 734 views
I'm trying to run a post install PowerShell script during a Scripted Installation that moves a system to a specific OU.  The script calls "Import-Module Activedirectory" and it looks like I'm getting an error saying the module is not available.  Are the ActiveDirectory modules available during the deploy?  My script runs after a 2nd reboot and the KACE menu comes up the script looks like it runs but it evidently does not complete.  When run manually it says the ActiveDirectory module cannot be found.

0 Comments   [ + ] Show comments


All Answers

Check this for how to install the modules: https://4sysops.com/wiki/how-to-install-the-powershell-active-directory-module/

This may also help from a scripting perspective: https://blogs.technet.microsoft.com/ashleymcglone/2016/02/26/install-the-active-directory-powershell-module-on-windows-10/

And in your PowerShell code you can check if the module exists like so:

if (Get-Module -ListAvailable -Name ActiveDirectory) {
It's also worth noting that you can move AD objects like computers without the ActiveDirectory module (albeit it it's not as nice...) - see the second post here:

Answered 05/23/2018 by: captain_planet
Black Belt