Wednesday, February 18, 2015

Powershell - Adding email address and other informational fields to AD in bulk

You setup your new domain imported or added user then realize you left out a field such as mail details. Since all users are different you can’t do a bulk select all and edit you have to set each one individually or via a .csv file and script. Here is a working example:

note: If your “user logon name” does not match your “user logon name (Pre-Windows 2000)” it will fail on those users.

Create an excel file with the following fields and export to a csv called c:\admailfield.csv

name mail

Create a .txt file and input the following

$users=import-csv C:\Source\admailfield.csv
foreach($user in $users){
$u = Get-ADUser $ -Properties mail
$u.mail = $user.mail 
Set-ADUser -instance $u

Save the file as admailfiled.ps1

Open powershell as an administrator on you local AD server and run


You can then use AD users and computers to confirm the changes were added to AD

Credit References:

DuRand Bryant

No comments:

Post a Comment