import active directory module powershell

How to Install and Import PowerShell Active Directory Module

Today we’ll show you how to install and use the Windows PowerShell Active Directory Module. You can use the cmdlets of this module to retrieve information and manage Active Directory. This module in the server OS is installed as a separate feature. On the desktop OS (Windows 10, 8.1, 7) the module is included in the Remote Server Administration Tools (RSAT). RSAT includes all the necessary management tools, command line utilities and Windows PowerShell modules for Windows servers and AD manage. You must download RSAT package for your version of the OS from the Microsoft website (how to install RSAT in Windows 10).

Active Directory Module for Windows PowerShell

The Active Directory module for Windows PowerShell first appeared in Windows Server 2008 R2. It is automatically installed on the domain controller. To use the PowerShell cmdlets from the Active Directory module, at least one controller with Windows Server 2008 R2 or higher must exist in your domain. If your network has only DCs with Windows Server 2003 or 2008, you must download and install the Active Directory Management Gateway Service. The PowerShell cmdlets from the Active Directory module interact with the web service that is part of the domain controller with the ADDS role or ADMGS.

READ ALSO  FSMO Role: Schema Master

You can install the Active Directory module for Windows PowerShell not only on the domain controller, but also on any Windows server or workstation.

In Windows Server 2016/Windows Server 2012 R2, you can install the Active Directory module for Windows PowerShell from the Server Manager graphical console using the Add Roles and Features Wizard. It is enough to start the wizard and at the stage of selecting features you need to select the item Remote Server Administration Tools > Role Administration Tools > AD DS and AD LDS Tools > Active Directory module for Windows PowerShell.

import active directory module

This module can also be installed using PowerShell. Open the PowerShell console as an administrator and run the following commands:

Import-Module ServerManager

Add-WindowsFeature -Name "RSAT-AD-PowerShell" –IncludeAllSubFeature

active directory module

In Windows 10, Windows 8.1, and Windows 7, to install the RSAT-AD-PowerShell module, you must first install the appropriate version of RSAT, then you need to enable the module (Control Panel > Programs > Turn Windows Features On or Off > Remote Server Administration Tools > Role Administration Tools > AD DS and AD LDS Tools > Active Directory module for Windows PowerShell).

powershell active directory module

Or using PowerShell:

Enable-WindowsOptionalFeature -Online -FeatureName RSATClient-Roles-AD-Powershell

Importing PowerShell Active Directory Module on Windows

In Windows 7 and Windows Server 2008 R2 with PowerShell 2.0 installed, to start using the Active Directory module, you need to import it into the PowerShell session with the command:

READ ALSO  FSMO Role: Infrastructure Master
import-module activedirectory

import module activedirectory

In addition, you can export the module from a remote computer or server and import it into your PowerShell session:

$S = New-PSSession -ComputerName MyDomainController

Export-PSsession -Session $S -Module ActiveDirectory -OutputModule RemoteAD

Remove-PSSession -Session $S

Import-Module RemoteAD

On Windows Server 2012 R2/2016 and Windows 8.1/Windows 10, the module is imported into the session automatically.

If the computer is included in the domain, by default a separate disk is created with the name AD:. You can go to this disk using the CD command and use the familiar commands of working with the file system to navigate this disk. The paths are in X500 format.

PS C:\> cd AD:
PS AD:\>
PS AD:\> dir
PS AD:\> cd "DC=contoso,DC=com"

PS AD:\> dir

active directory module for windows powershell

You can display the list of available cmdlets for working with Active Directory as follows:

Get-Command -Module ActiveDirectory

powershell import module activedirectory

Different versions of Windows (RSAT) have different number of cmdlets available:

  • Windows Server 2008 R2 — 76 cmdlets
  • Windows Server 2012 — 135 cmdlets
  • Windows Server 2012 R2/2016 — 147 cmdlets

So now you can use the PowerShell cmdlets to manage and query Active Directory.

You may also like:

Installing Active Directory Snap-in on Windows 10 One of the main Active Directory domain management tools is the MMC snap-in Active Directory Users and Computers (ADUC). To work with ADUC snap-in in ...
FSMO Role: Infrastructure Master We continue the series of articles about FSMO roles in the Active Directory domain. This time, we will take a closer look at the FSMO role — Infrastru...
How to transfer FSMO Roles From a Failed Domain Co... In case domain controller, which owns FSMO (Flexible Single Master Operation) roles, is fail (virus attack, fatal software problems or catastrophic ha...
How to hide specific OU in Active Directory The first thing you see while opening Active Directory Users and Computers (ADUC) snap-in is AD containers (Organization Unit, OU), in which user acco...
Change Default OU permissions in Active Directory By default, each newly created organizational unit (OU) in the access list includes read permission for the group Authenticated Users (built-in group)...

Add Your Comment