[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now


Script to auto populate AD field

Posted on 2013-11-14
Medium Priority
Last Modified: 2013-11-27
My managers are now looking to implement employee ID codes for all staff. Problem is that we have to do it for all existing and new staff. We have about 500 user accounts, doing it manually would be a nightmare. Is there a away for me to script something that would take an excel file containing account name + code and have the system automatically input the code into the correct AD account?
Question by:iamuser
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
  • 4
  • 2
  • 2
LVL 38

Assisted Solution

Mahesh earned 664 total points
ID: 39648303
You can create excel csv file and map all users employee code with samaccountname\logon name.
You can get employee code mapping from HR probably
Download Bulk AD users from Wisesoft.Its freeware.
It has feature called "csv update" which will allow you to update employee code attribute of all users in csv file.
Tool can be downloaded from below link.
LVL 40

Assisted Solution

Subsun earned 1336 total points
ID: 39648329
If you have Win 2008 R2 Domain controller then you can try..
Import-module ActiveDirectory
Import-CSV "C:\temp\Users.csv" | % {
Set-ADUser $_.User -employeeID $_.EmployeeID

Open in new window

Sample Input Users.csv file format..

Open in new window


Author Comment

ID: 39648367
Great 2 methods, with the software bulk ad user, can I use the first and last name + employee ID? Chances are HR will have it in that format rather than the username + employee ID.
Are You Ready for GDPR?

With the GDPR deadline set for May 25, 2018, many organizations are ill-prepared due to uncertainty about the criteria for compliance. According to a recent WatchGuard survey, a staggering 37% of respondents don't even know if their organization needs to comply with GDPR. Do you?

LVL 40

Accepted Solution

Subsun earned 1336 total points
ID: 39648425
By any methods you need to use the unique values to search for accounts... If you are sure that you have updated the correct first name and last name in AD as same as the HR data then you can use it to find the correct user. But keep in mind that AD allows duplicate first and last name for objects. So I would suggest you to use something like a email address or a samaccountname to find the user.
LVL 38

Expert Comment

ID: 39648440
You can map display name \ full name attribute with employee id
sAMAccountName is unique in AD, thats why I suggested you.
Anyways, i suggest you to export the user list from AD, and send it to HR in a format you want and ask them to fill up with Employee IDs
Bacause either you OR HR, somebody needs to do this mapping anyhow.
Hope that helps

Author Comment

ID: 39648447
As far as I know looking at AD all users (knock on wood) have unique names


Author Comment

ID: 39648452
Very true on that Mahesh

Author Closing Comment

ID: 39681655
Thanks, great advice

Featured Post

Has Powershell sent you back into the Stone Age?

If managing Active Directory using Windows Powershell® is making you feel like you stepped back in time, you are not alone.  For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why.

Question has a verified solution.

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

After seeing many questions for JRNL_WRAP_ERROR for replication failure, I thought it would be useful to write this article.
Microsoft Office 365 is a subscriptions based service which includes services like Exchange Online and Skype for business Online. These services integrate with Microsoft's online version of Active Directory called Azure Active Directory.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…
Suggested Courses

650 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