Wednesday, 4 February 2015

PowerShell: How to Import Active Directory module

If you are going to run Active Directory cmdlets in Powershell. You need to import Active Directory module before executing any cmdlet commands that exists in Active Directory powershell module.

Import Active Directory module:
Import-Module ActiveDirectory
Before start, ensure that the Active Directory module is installed or not by using following command. It will be installed by default in Domain Controller with the AD DS or AD LDS server roles. In client machine or member server (Windows 7 / 2008 R2 server), you need to install it through Remote Server Administration Tools.
Get-Module -Listavailable
How to Import Active Directory module in PowerShell

Install Active Directory module for Powershell:

If the Active Directory module is not installed already, follow the below steps to install.

- Download "Remote Server Administration Tools" from http://www.microsoft.com/download/en/details.aspx?id=7887 and install it
- Go to Windows Add/Remove Feature and enable Active Directory Module for Windows PowerShell. (Remote Server Administration Tools > Role Administration Tools > AD DS and AD LDS Tools > Active Directory Module for Windows PowerShell).

How to Install Active Directory module for PowerShell

Once you installed the Active Directory module for Powershell, you can run any cmdlet that exists in Active Directory Powershell module.
Import-Module ActiveDirectory
Get-ADUser -Identity "Morgan"

How to Import Active Directory module in PowerShell

If you are newbie to powershell, don’t forget to set your execution policy to unrestricted or you might get an error when you try run the script. Use the below command to set your execution policy:

Set-ExecutionPolicy Unrestricted
How to Import Active Directory module in PowerShell

Advertisements
Advertisements

No comments:

Post a Comment