0
0
PowershellHow-ToBeginner · 3 min read

How to Import AD Module in PowerShell Quickly

To import the Active Directory module in PowerShell, use the command Import-Module ActiveDirectory. This loads the AD cmdlets so you can manage Active Directory from your PowerShell session.
📐

Syntax

The basic syntax to import the Active Directory module is:

  • Import-Module: The PowerShell command to load a module.
  • ActiveDirectory: The name of the module that contains AD cmdlets.

This command makes AD commands available in your current PowerShell session.

powershell
Import-Module ActiveDirectory
💻

Example

This example shows how to import the AD module and then list all AD users using Get-ADUser cmdlet.

powershell
Import-Module ActiveDirectory
Get-ADUser -Filter * | Select-Object -First 5
Output
DistinguishedName : CN=Administrator,CN=Users,DC=example,DC=com Name : Administrator ObjectClass : user DistinguishedName : CN=Guest,CN=Users,DC=example,DC=com Name : Guest ObjectClass : user DistinguishedName : CN=krbtgt,CN=Users,DC=example,DC=com Name : krbtgt ObjectClass : user DistinguishedName : CN=User1,CN=Users,DC=example,DC=com Name : User1 ObjectClass : user DistinguishedName : CN=User2,CN=Users,DC=example,DC=com Name : User2 ObjectClass : user
⚠️

Common Pitfalls

Common mistakes when importing the AD module include:

  • Running Import-Module ActiveDirectory on a system without the module installed.
  • Using PowerShell versions or environments where the module is not available by default.
  • Not running PowerShell as Administrator when required.

To fix these, ensure the module is installed (usually via RSAT tools on Windows), use PowerShell 5.1 or later, and run with proper permissions.

powershell
Import-Module ActiveDirectory
# If you get an error like "Module not found", install RSAT tools first.

# Correct way:
# 1. Install RSAT (Remote Server Administration Tools) if missing
# 2. Run PowerShell as Administrator
# 3. Then run Import-Module ActiveDirectory
📊

Quick Reference

CommandDescription
Import-Module ActiveDirectoryLoads the Active Directory module into the current session
Get-Module ActiveDirectoryChecks if the AD module is loaded
Get-Command -Module ActiveDirectoryLists all commands available in the AD module
Remove-Module ActiveDirectoryUnloads the AD module from the session

Key Takeaways

Use Import-Module ActiveDirectory to load AD cmdlets in PowerShell.
Ensure RSAT tools are installed to have the AD module available.
Run PowerShell as Administrator if you face permission issues.
Check module availability with Get-Module before importing.
Use Get-Command -Module ActiveDirectory to explore available AD commands.