Solved

Translate mail attribute to username for bulk modify from csv file

Posted on 2011-03-18
10
655 Views
Last Modified: 2012-05-11
Hi I have a list of 3000 email addresses & I would like to bind to AD (translate mail to sAMaccountName if necessary?)) and modify the employeeNumber for each email address.

Is this possible using the email address?  If so how can this be done in powershell or vbs?
0
Comment
Question by:coch
[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
  • 5
  • 4
10 Comments
 
LVL 1

Expert Comment

by:crazyn3wf
ID: 35167687
are you trying to create User accounts? or are the account already there? and if the accounts already exist what are you trying to change?
0
 
LVL 13

Expert Comment

by:soostibi
ID: 35169036
Do you have an Exchange Server? How can we map user account to e-mail addresses?
0
 

Author Comment

by:coch
ID: 35176861
hi accounts already exist, I'm looking to modify each account with their employee number.  the data has been presented to me with the 'unique' mapping attribute being the smtp address in one co,ume and the employee number in the other.  

Exchange 2003 is in use.
0
Office 365 Training for IT Pros

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 13

Accepted Solution

by:
soostibi earned 500 total points
ID: 35177042
If you can have your userlist in this form of a CSV file:
    emplnum, email
    123456, administrator@ceg.hu
    ....


And if you have Quest's ActiveRoles.ADManagement snapin installed, you can use the following code to do the employee number import.
Add-PSSnapin Quest.ActiveRoles.ADManagement

import-csv c:\userlist.csv | %{Get-QADUser -Email $_.email | 
    Set-QADUser -ObjectAttributes @{employeeNumber = $_.emplnum} }

Open in new window

0
 

Author Comment

by:coch
ID: 35178687
Thanks but I dont currently have Active Roles installed, is there a way to do it without the add on?
0
 
LVL 13

Expert Comment

by:soostibi
ID: 35179244
Do you have a Windows Server 2008 R2 DOmain Controller?
0
 

Author Comment

by:coch
ID: 35180555
Yes
0
 
LVL 13

Assisted Solution

by:soostibi
soostibi earned 500 total points
ID: 35180768
Then you can use the activedirectory module:

Import-Module activedirectory
import-csv c:\userlist.csv | %{$email = $_.email; Get-ADUser -Filter "mail -eq '$email'" |   
    Set-ADUser -Replace @{employeeNumber = $_.emplnum} }

Open in new window

0
 
LVL 13

Assisted Solution

by:soostibi
soostibi earned 500 total points
ID: 35180820
Or, another version, if the csv file does not include the primary SMTP address, but any:

Import-Module activedirectory  
import-csv c:\userlist.csv | %{$email = "smtp:$($_.email); Get-ADUser -LDAPFilter "(proxyaddresses=$email)" |     
    Set-ADUser -Replace @{employeeNumber = $_.emplnum} }

Open in new window

0
 

Author Comment

by:coch
ID: 35209988
Thanks for such a detailed answer, sorry for the delay in commenting!
0

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

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

Suggested Solutions

My attempt to use PowerShell and other great resources found online to simplify the deployment of Office 365 ProPlus client components to any workstation that needs it, regardless of existing Office components that may be needing attention.
A hard and fast method for reducing Active Directory Administrators members.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

752 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