Solved

How to create multiple contacts in AD using scripts

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

If possible Tools Also...
0
Comment
Question by:Babcy
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 22

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
Office 365 Training for Admins - 7 Day Trial

Learn how to provision tenants, synchronize on-premise Active Directory, implement Single Sign-On, customize Office deployment, and protect your organization with eDiscovery and DLP policies.  Only from Platform Scholar.

 
LVL 22

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 22

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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

Recently, Microsoft released a best-practice guide for securing Active Directory. It's a whopping 300+ pages long. Those of us tasked with securing our company’s databases and systems would, ideally, have time to devote to learning the ins and outs…
Here's a look at newsworthy articles and community happenings during the last month.
This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles from a Windows Server 2008 domain controller to a Windows Server 2012 domain controlle…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

691 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