Windows PowerShell - Learn It Now Before It's an Emergency:
Earlier, Windows PowerShell was available as a separate add-on to Windows. Starting with Windows 7, Microsoft started to ship Products with PowerShell installed by default. Most or all of Microsoft's products will eventually use PowerShell as an administration tool. This demonstrates PowerShell’s importance in a windows administrator’s life in the 21st Century Era. That’s why Microsoft Scripting Guy Ed Wilson said ‘Learn It Now Before It's an Emergency’
My intention is not to go deeply into the nuance of PowerShell. I am going to get you started working on PowerShell right away. With such a simple introduction, I hope you'll be interested enough to dig deeper into the world of PowerShell on your own.
The Active Directory (AD) module is available by default with Windows 2008 R2 server (With the AD DS or AD LDS server roles.) . It can be installed as part of the Remote Server Administration Tools feature on a Windows 7 computer.
After installation you can access the PowerShell module using Active Directory Module for Windows PowerShell Console. To open the console Click on Start, then Go to >All Programs > Administrative Tools > Active Directory Module for Windows PowerShell
Or open a PowerShell console and load the Active Directory module with cmdlet Import-Module ActiveDirectory If you are getting following error, that means the ActiveDirectory module is not installed on the computer or the module files are not available at the PowerShell module path.
PS C:\> Import-Module Activedirectory
Import-Module : The specified module 'Activedirectory' was not loaded because no valid module file was found in any module directory.
At line:1 char:14
+ Import-Module <<<< Activedirectory
+ CategoryInfo : ResourceUnavailable: (Activedirectory:String) [Import-Module], FileNotFoundException
+ FullyQualifiedErrorId : Modules_ModuleNotFound,Microsoft.PowerShell.Commands.ImportModuleCommand
To ensure that you have the Active Directory module available for import, you can run the Get-Module –ListAvailable command in Windows PowerShell console.
Finding the AD cmdlets:
You can use the Get-Command cmdlet to retrieve all AD cmdlets.
Getting Help for AD cmdlets:
You can use Get-Help <cmdlet name> -Full or
Help <cmdlet name> -Full to get the complete help of the command.
Get-Help <cmdlet name> -Online will take you to the online help at Microsoft TechNet Library which will have a updated version of help.
Get-Help <cmdlet name> -Examples will return the examples of the cmdlet.
Common Active Directory cmdlets:
Following are the few cmdlets which we use frequently for the administration of Active directory objects.
How To Use Common Active Directory cmdlets:
For demo, I am using Get-ADuser to query Active Directory for all user objects..
Get-ADuser -Filter * will return all user objects in your AD.
By default the command will return the ten properties of the user object displayed in above screenshot. If you need to return additional properties you need to use -properties parameter.
For Example, Get-ADuser -Filter * -Properties Manager will return Manager Property in addition to the ten default properties.
You may add multiple properties with -Properties parameter, for example.
To select specific properties while exporting, you can use Select-Object command. Following command only export the properties 'Manager,DisplayName,Company' of all user objects to a csv file.
Another option to filter the result is to use Where-Object command. Following command will return the user objects which Company set as ‘Expert Exchange’
Comments (0)