Showing posts with label Add-ADGroupMember. Show all posts
Showing posts with label Add-ADGroupMember. Show all posts

Monday, June 11, 2012

Powershell and Active Directory: Powershell Script to create multiple groups in Active Directory and add predefined users in to it.


HI,

Sometime a need arrives when you need to create a few Active Directory groups and add the same members to all the groups.

Today i need to create 20 Group and need to add same users to all the groups. To create 20 Group manually and then add users to it one by one is a hectic job for me .

So again i thought let do it with PowerShell.

To achieve my goal i wrote a simple Powershell script. Make sure before running the script Make sure you have "RSAT" installed and imported the "Active Directory" Module.

You can download the script from : http://gallery.technet.microsoft.com/scriptcenter/Create-Multiple-Groups-in-4118c589

Screenshots
In testing OU i have only one Group Now.

11-06-2012 16-19-22

Run the script now and it ask you for Domain Administrator username and password.

11-06-2012 16-20-59

Ok...Script is finished with some Messages :)

11-06-2012 16-31-39

lets check our OU  and it has 4 New Groups.

11-06-2012 16-33-02

Lets Check inside the groups.

11-06-2012 16-33-15 11-06-2012 16-33-28 11-06-2012 16-33-46 11-06-2012 16-34-00 

All is well and done as per our requirements.

You can download the script from : http://gallery.technet.microsoft.com/scriptcenter/Create-Multiple-Groups-in-4118c589

Thanks!
Aman Dhally
Buy-More-Twitter-Followers   4fb29548b6adc
avatar-207

Thursday, June 7, 2012

Powershell and Active Directory: Add domain users to a group using powershell.

 

Hi,

Yesterday i shows you how to create a user group in "Active Directory". Now lets today add members to that user group using powershell.

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 Add-ADGroupMember cmdlet.

so we have a user group name as "Singers" which currently have no members.

07-06-2012 13-48-43

i am am planning to add "Michal Jackson" and "Rickey Martin" to the group.

07-06-2012 13-56-49

the command is below. Add-ADGroupMember and then Name of the Group and after that {SamName} name of the users delimitated by comma. and you can also provide -Server name if you want.

Add-ADGroupMember Singers Ricky.martin,Michael.jackson -Server "LocalDC"

07-06-2012 14-12-46

our command run successfully now lets check the Group see if our users are added to it..

07-06-2012 14-10-44

Bingo !! All DOne ...

Thanks for reading.

Thanks

Aman Dhally

Buy-More-Twitter-Followers   4fb29548b6adc

madagascar_penguin