Wednesday, June 6, 2012

Powershell and Active Directory: Create a new group in Active Directory using Powershell.



Yesterday one of my users asked me to create a few user group for him. Normally to create a new group i open "DSA.MSC" or "Active Directory users and computers" and create a desired group. This time i thought i would create a new group using PowerShell.

To create a new group in Active Directory make sure you have RSAT installed.

Lets Start.

 Make sure you have "RSAT" installed on you laptop.

Now Import the Active Directory module.

Import-Module ActiveDirectory

30-04-2012 23-21-03 


ok, Module is imported,,

we are going to use "New-ADGroup" cmdlet.

I want a group Name to be  "Singers", i my OU "Testing", the Group category in my case is "Security" and the Group Scope is "Global". I choose a -Server parameter because my main DC in located outside of Delhi and then using -Credential we are providing domain administrator username and password becasue you need administrator privileges to create a group in Active Directory.

The command should be like below.

New-ADGroup -Path "OU=testing,DC=localdc,DC=com" -Name "Singers" -GroupCategory Security -GroupScope Global -Server "local-dc" -Credential localdomain\administrator

After run the Command it is asking for Domain Administrator Credentials. Provide them.

06-06-2012 12-07-24 

Ok. Command run successfully without errors.

06-06-2012 12-08-24 

Let's check out OU "testing" and see if this group is created there.

Bingo.. all Done :)

06-06-2012 12-08-46 


Thanks for reading.


Aman Dhally



No comments:

Post a Comment