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
kevin.oppihle kevin.oppihle@domainname.com

Create a .txt file and input the following

$users=import-csv C:\Source\admailfield.csv
foreach($user in $users){
$u = Get-ADUser $user.name -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

 ./admailfield.ps1

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

Credit References:

DuRand Bryant

Comments

Popular posts from this blog

FRS to DFSR Post Cleanup “File Replication NtFrs Stopped”

Domain Migration SubinACL /Migratetodomain How To:

How to configure HP LaserJet Printer IPsec Encryption