Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How to create multiple contacts in AD using scripts

Posted on 2011-09-28
6
Medium Priority
?
1,722 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 1000 total points
ID: 36718378
0
 
LVL 10

Assisted Solution

by:ienaxxx
ienaxxx earned 1000 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
Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

 
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Always backup Domain, SYSVOL etc.using processes according to Microsoft Best Practices. This is meant as a disaster recovery process for small environments that did not implement backup processes and did not run a secondary domain controller that ne…
How to deal with a specific error when using the Enable-RemoteMailbox cmdlet to create a mailbox in the cloud-based service, for an existing user in an on-premises Active Directory.
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 …

610 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