Scripting Question

Scripted Install PowerShell AD move

05/22/2018 1231 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

This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ