?
Solved

AD Script to add/check groups and members

Posted on 2012-08-21
3
Medium Priority
?
495 Views
Last Modified: 2012-10-03
Hi,

I've been given an excel file with around 3,000 groups and it associated members for each group.

An extract from the excel sheet looks something like this:

Column A                Column B
GROUP NAME          MEMBERS
GroupA                    john.smith
GROUPB                  sally.carters
GROUPB                  connel.valentine
GROUPC                  raymond.simons
GROUPC                  william.soans

I've recieved some scripting to create the 3000 groups, so at the moment, I already have the groups created in AD. Now, I require some script to populate each group with members from the excel file i have above. It should follow the below logic:

- Check group name from column A
- Retrieve member name from column B
- Find the group in AD with the group name from column A
- Check if the group already has the member retrieved from column B
- If no, then add the member, if yes, then skip and go to the next row in the excel file
- REPEAT

Can anyone suggest some scripts on how i can achieve this?

Thanks for the support.
CV
0
Comment
Question by:connelvalentine
  • 2
3 Comments
 
LVL 24

Accepted Solution

by:
Nagendra Pratap Singh earned 1000 total points
ID: 38315376
You can even do it directly. Just add the member to the group. If the member is not there then it would be added. If is it a member then you get a small error message.

You need the DSMOD command.

dsmod group -addmbr "CN=Steven Carroll,CN=Users,DC=windowstoolkit,DC=local"

http://www.windowscommandsyntax.com/command-library/dsmod-group/

There are more examples on that link.
0
 

Author Comment

by:connelvalentine
ID: 38316064
Hi,

Thanks for the input, but i require code that will read the excel file and get it's information from there, and then go to the next line.

Kind of a FOR EACH...NEXT statement to be incorporated to traverse through the 300 lines.

CV
0
 

Author Closing Comment

by:connelvalentine
ID: 38457773
Not  a complete answer
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
What do responsible coders do? They don't take detrimental shortcuts. They do take reasonable security precautions, create important automation, implement sufficient logging, fix things they break, and care about users.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
Simple Linear Regression

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question