ADTips#1 – Install PowerShell Active Directory module

To run PowerShell command for Active Directory (Get-ADUser, Get-ADComputer, Get-ADGroup, New-ADUser, etc.), the PowerShell module msut be on the computer (workstation or server). There are two methods:

  1. with the Active Directory PowerShell module installation. It depends on your Windows version
  2. with module import via PSSession. This method is not very popular but can be very useful when you can’t install the PowerShell module. This method is described in the end of this article

Method 1: AD PowerShell module installation

Prerequisites

This module needs .NET Framework 3.5. For the recent Windows versions, you can enable it with :

dism /online /Enable-Feature /FeatureName:”NetFx3″

Windows 1810 and above

For client versions from Windows 10 october 2018 (Windows 1810), install Remote Server Administration Tool (RSAT) AD with Add-WindowsCapability via PowerShell as admin :

If you get error 0x800f0954, install .NET Framework 3.5

Windows 1803 and below

For Windows Windows 7/8/8.1, Windows 10 1803 and below, you need to install the RSAT according to your Windows version (french link) and restart your computer. Then, to enable RSAT AD via DISM (install all AD RSAT, not only the powershell ):

Windows Server 2012/2012R2/2016/2019

On Windows Server, the installation is made with the following PowerShell command:

Load the Active Directory module

Finally, after the AD module installation, if you run any AD CMDlet, PowerShell will automatically load the AD module. But in older PowerShell version, you need to load the module:

Import-Module ActiveDirectory

Method 2: Import module without installation

To use this method, you need the rights to Enter-PSSession on a computer with the AD PowerShell module installed. It can be either a domain controller or a member server/PC:

You only have to make this once. Indeed a .psm1 file containing the command to run PSRemoting session (against the PC/server in the following command) will be located in the Modules folder.

You can Import the Module with:

Import-Module RemoteActiveDirectory

It will load a PSSession to the computer. The script asks for credentials if you use a different account than the current one during the previous Enter-PSSession.

Keep in mind the following:

  • remote computer must be up when you execute the remote CMDlets
  • the CMDlet exeuction is a little longer than when the module is directly installed on the computer

And for the others PowerShell modules?

To enable other PowerShell module, go to the article with direct links to RSAT!

Leave a Reply

Close Menu