Solved

How to create multiple contacts in AD using scripts

Posted on 2011-09-28
6
1,462 Views
Last Modified: 2012-06-21
How to create multiple contacts in AD using scripts

If possible Tools Also...
0
Comment
Question by:Babcy
6 Comments
 
LVL 23

Accepted Solution

by:
Stelian Stan earned 250 total points
ID: 36718378
0
 
LVL 10

Assisted Solution

by:ienaxxx
ienaxxx earned 250 total points
ID: 36718394
Use the "dsadd contact" command in a batch looping on your list.



@echo off
For /F "usebackq delims=; tokens=1,2,3,4,5,*" %%a IN ("mylist.csv") DO(
 dsadd contact -fn %%a -ln %%b -mi %%c ........**
)

** Assuming you have a semicolon-separated list of contacts with a contact per row and have the First Name in the first column, the Last Name in the second, the middle initials in the third and so on.
Have a look at "dsadd contact /?" for parameters.


P.S.: remember to add more than five tokens if you have more than five columns....

HTH Bye!
0
 
LVL 21

Expert Comment

by:mcsween
ID: 36718419
You can do this easily with csvde.exe and a csv file.  See the link below for detailed info.  If you need further help just post here and I will be happy to assist.

http://technet.microsoft.com/en-us/library/cc787549(WS.10).aspx

To get the field names just use csvde to export a contact from AD and look at which filed names you want to fill.  to export all contacts from the OU "Contacts" in the domain mydomain.local and save them to c:\output.csv you would use the following.


csvde.exe -e -d "ou=Contacts,DC=mydomain,DC=local" -r "(objectclass=contact") -f c:\output.csv

Open in new window

0
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 
LVL 21

Expert Comment

by:mcsween
ID: 36718455
I had a double quote in the wrong place, correct command for export is below.  Also, csvde was specifically designed by microsoft to do this task.
csvde.exe -e -d "ou=Contacts,DC=mydomain,DC=local" -r "(objectclass=contact)" -f c:\output.csv

Open in new window

0
 
LVL 21

Expert Comment

by:mcsween
ID: 36718469
Ugh, I'm so sorry, don't use the -e switch; I'm trying to answer you and do something else at the same time and failing at both...
csvde.exe -d "ou=Contacts,DC=mydomain,DC=local" -r "(objectclass=contact)" -f c:\output.csv

Open in new window

0
 

Author Closing Comment

by:Babcy
ID: 36816422
Thanks Team
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Do you have users whose passwords are expiring and they are constantly calling you?  Well I sure did and needed a way to put an end to this.  We have a lot of remote users which would not be notified that their passwords were expiring since they wer…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
This tutorial will walk an individual through the steps necessary to join and promote the first Windows Server 2012 domain controller into an Active Directory environment running on Windows Server 2008. Determine the location of the FSMO roles by lo…
This tutorial will walk an individual through the process of configuring their Windows Server 2012 domain controller to synchronize its time with a trusted, external resource. Use Google, Bing, or other preferred search engine to locate trusted NTP …

911 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

Need Help in Real-Time?

Connect with top rated Experts

25 Experts available now in Live!

Get 1:1 Help Now