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
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).
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"
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