Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 664
  • Last Modified:

Translate mail attribute to username for bulk modify from csv file

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
coch
Asked:
coch
  • 5
  • 4
3 Solutions
 
crazyn3wfCommented:
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
 
soostibiCommented:
Do you have an Exchange Server? How can we map user account to e-mail addresses?
0
 
cochAuthor Commented:
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
Lessons on Wi-Fi & Recommendations on KRACK

Simplicity and security can be a difficult  balance for any business to tackle. Join us on December 6th for a look at your company's biggest security gap. We will also address the most recent attack, "KRACK" and provide recommendations on how to secure your Wi-Fi network today!

 
soostibiCommented:
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
 
cochAuthor Commented:
Thanks but I dont currently have Active Roles installed, is there a way to do it without the add on?
0
 
soostibiCommented:
Do you have a Windows Server 2008 R2 DOmain Controller?
0
 
cochAuthor Commented:
Yes
0
 
soostibiCommented:
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
 
soostibiCommented:
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
 
cochAuthor Commented:
Thanks for such a detailed answer, sorry for the delay in commenting!
0

Featured Post

NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

  • 5
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now