/
/

How to Install & Import PowerShell Active Directory Module

How to Install & Import PowerShell Active Directory Module blog banner image

Key Points

How to Install the Active Directory PowerShell Module

  1. Open PowerShell as Administrator → Right-click PowerShell > Run as Administrator.
  2. Run: Add-WindowsCapability -Online -Name "Rsat.ActiveDirectory.DS-LDS.Tools~~~~0.0.1.0"

How to Import the Active Directory PowerShell Module

  1. Open PowerShell as Administrator.
  2. Import the module: Import-Module ActiveDirectory
  3. Verify import: Get-Command -Module ActiveDirectory

How to Auto-Load the Module in PowerShell

  1. Check if a profile exists: Test-Path $Profile
  2. If False, create a profile: New-Item -Path $Profile -ItemType File -Force
  3. Open profile in Notepad: notepad $Profile
  4. Add the following line and save: Import-Module ActiveDirectory

Managing Active Directory, the heart of Windows network infrastructure, presents unique challenges. From user account management to group policy configurations, administrative tasks can be complex and time-consuming. That’s where PowerShell, Microsoft’s powerful scripting language, comes in. It has become a game-changer for automating administrative tasks. 

In this guide, we introduce the PowerShell Active Directory Module, exploring its role in simplifying management tasks, and how to install and import it efficiently.

Simplify AD management using PowerShell and NinjaOne’s powerful automation tools.

→ Take control with NinjaOne Active Directory Management.

What is the PowerShell Active Directory Module?

The PowerShell Active Directory Module is a set of commandlets, or cmdlets, that facilitate the management of Active Directory. Cmdlets are lightweight commands used in PowerShell for specific administrative tasks.

The Active Directory Module acts as a bridge between the Windows PowerShell environment and the directory service, providing administrators with a powerful toolset to automate and streamline tasks, as well as cleaning up Active Directory.

PowerShell has evolved over the years, reflecting Microsoft’s commitment to improving the administrative experience for IT professionals. The Active Directory Module was initially introduced as a separate installation, but the module has become an integral part of Windows Server editions, making it more accessible and ensuring that the latest features are readily available.

Simplifying Active Directory management

The PowerShell Active Directory Module simplifies the management of Active Directory by providing a consistent and efficient scripting interface. Rather than relying on graphical user interfaces (GUIs), administrators can leverage PowerShell scripts to perform tasks such as creating user accounts, modifying group memberships, and managing organizational units.

Once tested and validated, these automations not only reduce the likelihood of human error but also significantly speed up the execution of repetitive tasks, freeing up time for other duties.

Installing, importing, and loading modules

In PowerShell, understanding the distinction between installing, importing, and loading modules is crucial. 

  • Install-Module: This command is used to download and install a module from an online repository like the PowerShell Gallery. It’s typically used when you want to add a new module to your system.
  • Import-Module: Once a module is installed, the Import-Module cmdlet makes its cmdlets available for use in the current PowerShell session. This is necessary to execute the cmdlets and leverage the module’s functionality.
  • Load-Module: The Load-Module cmdlet loads a module into the current session’s memory, making its cmdlets available for use without importing. This approach is beneficial when you want to keep the module in memory for an extended period or when dealing with large modules to minimize loading times.

Install Active Directory PowerShell Module

Before installing the Active Directory PowerShell Module, ensure that your system meets the following requirements:

  • Operating system: Windows Server is recommended for server installations, while Windows 10 or Windows 11 are suitable for client installations. Take note that the following instructions only work for Pro, Enterprise, or Education editions only. It is not available on Home.
  • PowerShell version: Ensure that you have PowerShell 5.1 or later installed on your system.
  • Must be connected to the AD server: The machine where the module is being installed must be connected to an AD server; otherwise, it will send an error when importing the module.
  • Remote Server Administration Tools (RSAT): Depending on your Windows version, you may need to install RSAT, which includes the Active Directory module.
  • Internet access: Ensure that your system has internet access to download the module from the PowerShell Gallery. If your system is behind a proxy, you may need to configure proxy settings for PowerShell.

The steps required to install the Active Directory PowerShell Module vary slightly depending on your Windows operating system version. Some versions require additional pop-ups and confirmation dialogues. 

These are the core steps:

  1. Right-click the PowerShell icon and select “Run as Administrator” to open a PowerShell session with elevated privileges.
  2. Enter the following command:

Add-WindowsCapability -Online -Name "Rsat.ActiveDirectory.DS-LDS.Tools~~~~0.0.1.0"

⚠️ Note: This only works if you’re using a supported edition (Pro, Enterprise, or Education). RSAT is not available in Windows Home.

  1. Restart your computer to apply the changes.

Import Active Directory PowerShell Module

Once the module is installed, it needs to be imported into your PowerShell session before you can start using its cmdlets. Importing loads the module into memory, making its functionality available for execution:

  1. Open a new PowerShell session. You do not need to run as an admin this time (though it’s recommended).
  2. Run this command:

Import-Module ActiveDirectory

  1. Confirm it’s working by running this command:

Get-Command -Module ActiveDirectory

💡 If the module is active, you’ll see a list of available cmdlets like Get-ADUser and New-ADGroup.

Loading the module efficiently

To ensure that the Active Directory module is loaded automatically when you open a PowerShell session, you can add the import command to your PowerShell profile script. This script runs every time you open a new PowerShell session:

  1. Check if a profile exists: To do this, open PowerShell and run the following command to check if you have a profile script:

Test-Path $Profile

If the command returns False, you need to create a profile (step 2). If it returns True, proceed to step 3.

  1. Create a profile (if needed): If you don’t have a profile, create one using the following command:

New-Item -Path $Profile -ItemType File -Force 

  1. Edit the profile script: Open your profile script in a text editor. You can use Notepad or any other code editor you prefer. Run the following command to open the profile in Notepad:

notepad $Profile 

  1. Add Import-Module line: In the profile script, add the following line to import the Active Directory module. Ensure that the path specified matches the actual path where the module is installed:

Import-Module ActiveDirectory

  1. Save and close Notepad.

Easily manage Active Directory users with NinjaOne.

→ Watch a free demo

Optional: Fix script execution errors

If you try to run a script and receive the error, “running scripts is disabled on the system”, you may have issues with a PowerShell execution policy. To check:

  1. Open PowerShell as an administrator.
  2. Run the command:

Get-ExecutionPolicy

If it returns as Restricted, it means that scripts are blocked.

  1. Change the policy for your user. In another PowerShell window, run this command:

Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser

✅ RemoteSigned allows local scripts to run and requires downloaded scripts to be signed by a trusted publisher.

When prompted, type Y and press Enter.

Simplify AD management with the PowerShell Active Directory Module

The PowerShell Active Directory Module is more than a tool – it transforms the way Active Directory tasks are approached. Armed with data gathered by advanced Active Directory management tools, it is easy to create scripts that maximize administrative efficiency.

As technology continues to evolve, leveraging tools like the PowerShell Active Directory Module becomes a necessity for administrators looking for ways to optimize their environments. Empower your scripts, automate your tasks, and let the PowerShell Active Directory Module be the foundation of your Active Directory management excellence.

You might also like

Ready to simplify the hardest parts of IT?
×

See NinjaOne in action!

By submitting this form, I accept NinjaOne's privacy policy.

NinjaOne Terms & Conditions

By clicking the “I Accept” button below, you indicate your acceptance of the following legal terms as well as our Terms of Use:

  • Ownership Rights: NinjaOne owns and will continue to own all right, title, and interest in and to the script (including the copyright). NinjaOne is giving you a limited license to use the script in accordance with these legal terms.
  • Use Limitation: You may only use the script for your legitimate personal or internal business purposes, and you may not share the script with another party.
  • Republication Prohibition: Under no circumstances are you permitted to re-publish the script in any script library belonging to or under the control of any other software provider.
  • Warranty Disclaimer: The script is provided “as is” and “as available”, without warranty of any kind. NinjaOne makes no promise or guarantee that the script will be free from defects or that it will meet your specific needs or expectations.
  • Assumption of Risk: Your use of the script is at your own risk. You acknowledge that there are certain inherent risks in using the script, and you understand and assume each of those risks.
  • Waiver and Release: You will not hold NinjaOne responsible for any adverse or unintended consequences resulting from your use of the script, and you waive any legal or equitable rights or remedies you may have against NinjaOne relating to your use of the script.
  • EULA: If you are a NinjaOne customer, your use of the script is subject to the End User License Agreement applicable to you (EULA).