How to add Active Directory module in PowerShell in Windows 7

If you are planning to run a Powershell script with Active Directory commandlets on a Win 7 machine or any other machine that DOES NOT have AD role then you need to do some preliminary steps as listed below.




By default one can not import Active Directory module in Powershell in Windows 7. You need to do either of the below:


By doing this you will get the Active directory module to be used in the Power shell scripting.


In this article I have explained the steps for Windows 7.




After the installation of the KB958830 go to Windows Feature and enabled the highlighted items as below.


Comments (18)
  1. Lepide says:

    I have followed all the steps above for my Windows 7 machine

    PS C:> import-module ActiveDirectory

    Import-Module : Cannot find drive. A drive with the name ‘ C’ does not exist.

    At line:1 char:14

    + import-module <<<< ActiveDirectory

    + CategoryInfo : ObjectNotFound: ( C:String) [Import-Module], DriveNotFoundException

    + FullyQualifiedErrorId : DriveNotFound,Microsoft.PowerShell.Commands.ImportModuleCommand

  2. Lepide says:

    Microsoft Scripting Guy Ed Wilson here. Last week’s Windows PowerShell workshop in Seattle was a lot of fun. The students were really engaged and asked some great questions. My friend from Philadelphia, Pennsylvania, is out there this week doing an Exchange workshop. Anyway, during the class, I decided it would be a good idea to use Windows PowerShell remoting to perform Active Directory administration. In this way, I avoided the need to install the Remote Server Administration Tools (RSAT) on the client machine.

    The first thing to do is to enter a remote Windows PowerShell session. To do this I use the Enter-PSSession cmdlet. I specify the computername and the credentials for the remote session. The credentials is an account that has the administrator rights on the remote machine. This command is shown here:

    Enter-PSSession -ComputerName dc1 –credential nwtradersadministrator

    If I the account I am using for my client computer also has administrator rights on the remote machine, I can leave off the credential parameter. After I have entered the session, I generally set my working location to the root of the drive so that I have more space for my commands. I then import  the ActiveDirectory module. These commands appear are shown here:

    Set-Location c:

    Import-Module activedirectory

    The commands and the associated output are shown in the following image. Note how I use the aliases for the commands because it makes it easier to type.

    Now I will create a new user in Active Directory. I think I will name the user ed. The command to create a new user is simple; it is New-ADUser and the user name. The command to create a disabled user account in the users container in the default domain is shown here:

    new-aduser -name ed

    When the preceding command that creates a new user has completed, nothing is returned to the Windows PowerShell console. To check to ensure the user is created, use the Get-ADUser cmdlet to retrieve the user object:

    Get-aduser ed

    When I am certain my new user is created, I decide to create an organizational unit (OU) to store the user account. The command to create a new OU off the root of the domain is shown here:

    new-ADOrganizationalUnit scripting

    Just as with the previously used New-ADUser cmdlet, nothing is returned to the Windows PowerShell console. If I use the Get-ADOrganizationalUnit cmdlet, I must use a different methodology. A simple Get-ADOrganizationalUnit command returns an error; therefore, I use an LDAPFilter parameter to find the OU. The command using the LDAPFilter parameter to find my newly created OU is shown here:

    Get-ADOrganizationalUnit –LDAPFilter "(name=scripting)"

    The commands and associated output to create the user, get the user, create the OU, and get the OU are shown in the following figure.

  3. Thanks RameshRK, it worked beautifully (on Windows 7 x64) and helped me understand my AD groups.

  4. Rafał says:


    this wont work @ win7 x86

    PS C:Usersfunio> Import-Module activedirectory

    Import-Module : The specified module 'activedirectory' was not loaded because no valid module file was found in any mod

    ule directory.

    i have the same problem @ Server 2008 STD (old EBS 2008)

  5. Chris Padilla says:

    In order to install the Active Directory Module for Windows PowerShell you need to

    1)  Download the RSAT tools for Windows 7.

    2)  Navigate to Control Panel > Programs and Features > Turn Windows Features On or Off and select Active Directory Module for Windows PowerShell

  6. Ed K says:

    Is there anyway to make the module always available for use when I start powershell?

  7. Bo says:

    Needed this also, and just tried example from Mr. Wilson.  Everything went well until I in-put the password, (which I know is correct) and received the following error text:

    Enter-PSSession : Connecting to remote server failed with the following error message : The WinRM client cannot process the request. If the authentication scheme is different from Kerberos, or if the client computer is not joined to a domain, then HTTPS transport must be used or the destination machine must be added to the TrustedHosts configuration setting. Use winrm.cmd to configure TrustedHosts. Note that computers in the TrustedHosts list might not be authenticated. You can get more information about that by running the following command: winrm help config. For more information, see the about_Remote_Troubleshooting Help topic.  At line:1 char:16

    + Enter-PSSession <<<<  -ComputerName DukeDC -credential PRE.netPyxis-Support

       + CategoryInfo          : InvalidArgument: (DukeDC:String) [Enter-PSSession], PSRemotingTransportException

       + FullyQualifiedErrorId : CreateRemoteRunspaceFailed

    I have tried searching for what I am missing here, but am coming up blank.  Any insight will be appreciated.

    Thank  you

  8. patrick says:

    %windir%system32WindowsPowerShellv1.0powershell.exe -noexit -command import-module ActiveDirectory

  9. Bo,

    enable psremoting on the remote host first.

    PS C:>enable-psremoting -force

  10. says:

    I found a very Simple and elegant way to make the AD Powershell Module Portable.

    you will need 3 simple things

    1.) the ActiveDirectory Module Directory from a system that has it already installed.  

    Standard path on a 64bit windows 7


    2.)  Global Assembly Cache Utility

    Available from the Windows SDK


    3.) the Microsoft.ActiveDirectory.Management dll assembly

    found on a system that already has the RSAT and powershell enabled. Microsoft.ActiveDirectory.Management.dll

    Now in order to make this work you need to install the dll using the gacutil program.  commandline is as follows.

    GACUTIL.exe -I Microsoft.ActiveDirectory.Management.dll

    Once installed you must copy the entire directory from item 1 to the powershell module location.

    Once copied you can then use the import command to import it and start using the cmdlets.  below is my batch file I wrote to automate this for deployment during SCCM.

    We want our help desk to be able to clone security groups assigned to our computers for application deployment so that when they image a replacement computer the new computer will automatically get the previously assigned applications.  Also see below for that powershell script as well.  Hope this helps the community.

    REM ************************************

    REM SET Working Directory

    REM ************************************

    @setlocal enableextensions

    @cd /d "%~dp0"

    REM ************************************

    REM Copy Module

    REM ************************************

    if not exist C:WindowsSystem32WindowsPowerShellv1.0ModulesActiveDirectory mkdir C:WindowsSystem32WindowsPowerShellv1.0ModulesActiveDirectory

    xcopy /y /e .ActiveDirectory*.* C:WindowsSystem32WindowsPowerShellv1.0ModulesActiveDirectory

    REM ************************************

    REM Install Microsoft Active Directory Assembly

    REM ************************************

    gacutil.exe -i Microsoft.ActiveDirectory.Management.dll

    REM ************************************

    REM Set Powershell Execution Policy

    REM ************************************

    powershell set-executionpolicy remotesigned

  11. Kevin says:


    Just wanted to thank you for the tips and script.  Worked like a champ (though my desktops are taking way longer to load the module than I would like).

    Just a couple of notes:

    1.  I was able to get the GACUtil from the Visual Studio install under C:Program FilesMicrosoft SDKsWindowsv8.0Abin .  Keep in mind that this file is not supposed to be distributed per the licensing agreement so you can't give it out to others.

    2. I had to do a search under C:Windows to find the DLL and I found both x64 and x86, though they appear to be the same file.

    Thanks again!

  12. mseron says:

    You still need an active directory 2008 as the 2003 does not support this feature

  13. pregunton says:

    How do it using powershell ?

    Navigate to Control Panel > Programs and Features > Turn Windows Features On or Off and select Active Directory Module for Windows PowerShell

    Activate feature Active Directory Module for Windows PowerShell programmatically ?

  14. drreid says:

    Hey All,

    I'm trying to install the software (Windows6.0-KB968934-x86) from the link at the top on Server 2008 R2 32 bit. I get error "The update does not apply to your system".  I also tried other 3 packages just in case but as expected they didn't work either. Any Ideas?

    Thanks In Advance,

  15. RLucas says:

    1.Download and install Remote Server Administration Tools for Windows 7 (…/details.aspx)

    •NOTE: Select either the x86 or x64 version, as appropriate for your Windows 7 workstation.

    •NOTE: The installer may seem inactive for some time. This is normal.

    2.Once the installation is complete, navigate to the Control Panel and select Programs and Features, and click Remote Server Administration Tools.

    3.Select AD DS and AD LDS Tools and then select Active Directory Module for Windows PowerShell.

    4.Open a PowerShell prompt and type PS C:> Get-Module –ListAvailable.

    5.To ensure the Active Directory Module is present, using PowerShell type PS C:> Import-Module ActiveDirectory.

    •NOTE: You will need to do this for every PowerShell session.

    6.If you wish to have the Active Directory Module automatically loaded any time you run PowerShell, prepare a shortcut with the following content: %windir%system32WindowsPowerShellv1.0powershell.exe -noexit -command import-module ActiveDirectory

    7.Open a new PowerShell session using the shortcut prepared above and run Get-Module.

  16. DerpingTon says:

    Remember to check the "Active Directory For Powershell Module" box because if you only select the "Parent" box it doesn't check the children.  

  17. PowerShell says:

    Is there a way to get the members of a distribution group listed as output, via powershell or otherwise? Not the objectclass, GUID, SID etc, only user names.

  18. Jose Cuervo says:


    I hate to tell you this, but this software only works for certain versions of Windows 7. If you get that message, your version of Windows 7 is not one of those. So the message that you received is in fact correct. Have a good day.

Comments are closed.

Skip to main content