You want to know how to install the PowerShell Active Directory module on Windows 7, Windows 8, Windows 8.1, Windows Server 2008 R2, and Windows Server 2012 R2? This is your guide.
Profile gravatar of Michael Pietroforte

Michael Pietroforte

Michael Pietroforte is the founder and editor of 4sysops. He is a Microsoft Most Valuable Professional (MVP) with more than 30 years of experience in IT management and system administration.
Profile gravatar of Michael Pietroforte

The PowerShell Active Directory module offers a variety of cmdlets that allow you to remotely manage Active Directory. Many guides exist on the Internet that explain how to install the PowerShell Active Directory module. Unfortunately, many of them are incomplete or confuse the different Windows versions. I’ve tried all installation procedures in this article, so you shouldn’t run into unforeseen trouble.

Windows 7 ^

The Active Directory module is part of the Remote Server Administration Tools (RSAT), which you have to download first. After the installation is complete, open the Control Panel, start typing “features,” and then click Turn Windows features on or off. Scroll down to Remote Server Administration Tools and enable Active Directory Module for Windows PowerShell in Remote Server Administration Tools > Role Administration Tools > AD DS and AD LDS Tools.

Installing the Active Directory Module for Windows PowerShell in Windows 7

Active Directory Module for Windows PowerShell on Windows 7

Many guides stop here. However, if you then run a cmdlet such as Get-ADUser from the Active Directory module, you will receive the error message “The term ‘Get-ADUser’ is not recognized as the name of a cmdlet…” even though the module is installed. The reason is that PowerShell 2 in Windows 7 doesn't support automatic cmdlet discovery and module loading and you therefore have to import the Active Directory Module module manually. If you already updated to PowerShell 3 or higher, you don't have to follow the procedure below. To import the module, you have to type the following at a PowerShell prompt:

Another option is to open the module from the Administrative Tools folder in the Control Panel.

Active Directory Module in Administrative Tools

Active Directory Module in Administrative Tools

Unfortunately, this is still not enough to completely install the Active Directory Module. All we have done so far is run the module. If you launch a new PowerShell session, the module will not load again. To make the import of the module permanent, you have to run the import command in your PowerShell profile.

Several locations exist where you can store your profile. If you want to import the module for your account only, you can add the command Import-Module ActiveDirectory to %UserProfile%\My Documents\WindowsPowerShell\profile.ps1. This will also automatically import the module in PowerShell ISE. If you only want to import the module in the PowerShell console, you would add the above command to Microsoft.PowerShell_profile.ps1.

Note that your profile script will only run if your PowerShell execution policy is set to RemoteSigned or Unrestricted. If you didn’t change the default execution policy, you can configure it with this command:

Windows Server 2008 R2 ^

If your Windows Server 2008 R2 machine is a domain controller, the PowerShell Active Directory Module is already installed. You only have to install the module on member servers. The procedure in Windows Server 2008 R2 is similar to that in Windows 7. (Note that the module is not available for Windows Server 2008.)

One difference is that you don’t have to download RSAT because the tools are already available on Windows Server 2008 R2. In Server Manager, you have to click Add features and then select Active Directory module for Windows PowerShell in Remote Server Administration Tools > Role Administration Tools > AD DS and AD LDS Tools.

Installing the module on Windows Server 2008 R2

Installing the module on Windows Server 2008 R2

Alternatively, you can install the module from a PowerShell console:

After the module has been copied to your computer, you have to import it:

Alternatively, you can right-click the PowerShell icon in the taskbar and select Import system modules.

Import system modules

Import system modules

As on Windows 7, if you want to make the import permanent, you have to add the above import command to your PowerShell profile. Notice that this description assumed that you didn't update PowerShell 2 on your Windows Server 20o8 R2 machine (see description about Windows 7).

Windows 8 and Windows 8.1 ^

Things are a lot easier in Windows 8 and Windows 8.1. All you have to do is download (Windows 8, Windows 8.1) and install RSAT. By default, all tools are enabled after the installation, and you also don’t have to import the module. You can use the Active Directory Module right away after you install RSAT. So, never spread the myth again that Windows 7 is better than Windows 8. 😉

Windows Server 2012 and Windows Server 2012 R2 ^

As on Windows Server 2008 R2, the Active Directory Module is already installed on domain controllers on Windows Server 2012 and Windows Server 2012 R2. On member servers, you can add the module as a feature in Server Manager. Enable Active Directory module for Windows PowerShell in Remote Server Administration Tools > Role Administration Tools > AD DS and AD LDS Tools.

Installing the module on Windows Server 2012 R2 in Server Manager

Installing the module on Windows Server 2012 R2 in Server Manager

Alternatively, you can install the module from a PowerShell console:

Installing the Active Directory Module on Windows Server 2012 with PowerShell.

Installing the Active Directory Module on Windows Server 2012 with PowerShell

There is no need to import the ServerManager module first, as on Windows Server 2008 R2. You also don’t have to import the Active Directory module after the installation.

If you want to verify the module was installed successfully, you can just run the Get-ADUser cmdlet. In my next post i will give an example of what you can do with the Active Directory module.

Take part in our competition and win $100!

Share
2+

Related Posts

18 Comments
  1. avatar
    Nazir 11 months ago

    When attempting to import AD module to %UserProfile%\My Documents I receive the following error:

    powershell a positional parameter cannot be found that accepts argument '%UserProfile%\My'.

    At line:1 char:1

    Any help would be very much appreciated.

    0
    • Profile gravatar of Michael Pietroforte Author
      Michael Pietroforte 11 months ago

      Can you post the exact command you are using?

      0
      • avatar
        Nazir 11 months ago

        PS C:\> Import-Module ActiveDirectory %UserProfile%\My Documents\WindowsPowershe
        ll\profile.ps1
        Import-Module : A positional parameter cannot be found that accepts argument
        '%UserProfile%\My'.
        At line:1 char:1
        + Import-Module ActiveDirectory %UserProfile%\My
        Documents\WindowsPowershell\profi ...
        + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        ~~~
        + CategoryInfo          : InvalidArgument: (:) [Import-Module], ParameterB
        indingException
        + FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell
        .Commands.ImportModuleCommand

        0
  2. avatar
    Nazir 11 months ago

    S C:\> Import-Module ActiveDirectory %UserProfile%\My Documents\WindowsPowershe
    ll\profile.ps1

    I have put also put it in quotation marks as there is a space in the name of the directory, but this also did not work.

    0
    • Profile gravatar of Michael Pietroforte Author
      Michael Pietroforte 11 months ago

      You have to use $env:userprofile instead of %UserProfile%\ What is profile.ps1 for?

       

      0
      • avatar
        Nazir 11 months ago

        Forgive my ignorance, I'm assuming the command will create a .ps1, so that each time I run PowerShell from within my profile, it will execute the AD module import automatically.

        Anyways, it still throwing the same error, but this time it has recognised/picked up my profile name. I'll go away and spend a bit of time researching t o resolve this and post any findings that may help anyone.

        Thank you for your time so far.

        0
  3. Profile gravatar of Michael Pietroforte Author
    Michael Pietroforte 11 months ago

    If you want to load a module automatically, you have to copy it to a module folder. Run $env:PSModulePath to get a list of your module folders.

    0
  4. avatar
    Scott 11 months ago

    Your issue is the space between My and Documents.  The line should read:

    Import-Module ActiveDirectory "$env:userprofile\My Documents\WindowsPowershell\profile.ps1"

    However, this is not what the article said do.  It said add:

    Import-Module ActiveDirectory

    To:

    "$env:userprofile\My Documents\WindowsPowershell\profile.ps1"

    So what you could do is the following to append the commend to the existing profile.ps1 or create it if missing.

    Import-Module ActiveDirectory >> "$env:userprofile\My Documents\WindowsPowershell\profile.ps1"

    0
  5. avatar
    Moin 9 months ago

    i am using windows server r-2 but cannot fount AD-Lds tools

    0
  6. avatar
    ursJAR 9 months ago

    I am using PowerShell on my macOS. Can I import the AD module to manage my AD from macOS?

    0
  7. avatar
    Sergey 8 months ago

    I have this type of error (PowerShell 2.0, Win7 64 bit SP1) after having done all manipulations.

    "WARNING: Default drive initialization error: "Can not find a default server with Active Directory Web Services running"

    0
  8. avatar
    Sergey 8 months ago

    The answer

    "A key requirement to use the AD cmdlet’s to manage an Active Directory deployment is the following:

    A Windows Server 2008 R2 Active Directory Web Services (ADWS) service must be installed on at least one domain controller in the AD domain or on one server that hosts your AD LDS instance. For more information about ADWS, see AD DS: Active Directory Web Services (http://go.microsoft.com/fwlink/?LinkID=141393).

    If you receive this error:

    ‘Unable to find a default server with Active Directory Web Service running’"

    You do not have ADWS installed on at least one DC.

    1+

    Users who have LIKED this comment:

    • avatar
  9. avatar
    Dennis Graham 5 months ago

    Michael,

    Thank you for giving so much to the community and for this article in particular.  I recall the euphony that the PS community had when Windows Server 2008 R2 came out.  My question is can AD Modules and functionality be done on a Windows Server 2008 R1 Server; and are there instructions on how to accomplish this?

    Dennis

    0
    • Profile gravatar of Michael Pietroforte Author
      Michael Pietroforte 5 months ago

      Dennis, thanks! Do you mean Windows Server 2008 R2 or Windows Server 2008? There is no R1. On R2, it should work (as discussed in the article). I am unsure if the AD module works on Windows Server 2008 because this Windows version only supports PowerShell 2. I think you will need this.

      0
  10. avatar
    Harry 4 months ago

    Installed AD module for powershell in windows 7 . AD-getcomputer command works but it doesnot recognizes "-properties *" . Any idea

    0

Leave a reply

Your email address will not be published. Required fields are marked *

*

CONTACT US

Please ask IT administration questions in the forum. Any other messages are welcome.

Sending
© 4sysops 2006 - 2017

Log in with your credentials

or    

Forgot your details?

Create Account