Change of Name in Active Directory and Exchange on premises through Powershell

Pavan Joshi
Pavan Joshi used Ask the Experts™
Hi Friends,

I need a script to perform below tasks for one user using a CSV:

1. Change First Name, Last Name, Display Name (Name, Display) Format
2. Change Email address in Active Directory
3. Access exchange server and change Primary SMTP and add another additional alias

Can any one help me writing a script for this.. If any info needed I can provide. Please help me on this task as it will help us greatly.

Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
LeoSnr Network Eng

Try the script link I have pasted below, there are two scripts one will overwrite the existing data & other will only write if existing attributes are blank.

Prerequisites:- quest management tools should be installed.
Senior Solution Architect
Most Valuable Expert 2015
Top Expert 2015
This is quite simple. Use the script below. Let me know if you have any issues...

CSV should be constructed like below...

sam            First    Last       DisplayName   NewPrim                                     AdditionalAlias
 msmith     Mike   Smith    Mike Smith
 jlows          Jean    Lows     Jean Lows        

Import-Module activedirectory
$Data = Import-csv "c:\filename.csv"

    ForEach ($line in $Data) 

            Set-ADUser -Identity $line.sam -GivenName $line.First -Surname $line.Last -DisplayName $line.DisplayName

            Set-Mailbox -Identity $line.sam -EmailAddressPolicyEnabled $false -EmailAddresses $line.AddtionalAlias

            Set-Mailbox -Identity $line.sam -PrimarySmtpAddress $line.NewPrim


Open in new window

You need to change the second line "Add-PSSnapin" to whatever version of Exchange you are running. You need to have both Active Directory and Exchange snapins in the powershell session for this to work as we are calling different cmdlets.



I've requested that this question be deleted for the following reason:

I got the answer
Ensure you’re charging the right price for your IT

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!

Will SzymkowskiSenior Solution Architect
Most Valuable Expert 2015
Top Expert 2015

All that work and your clsoing the question, with no explaination? I have tested my script and it does exactly what you asked.

LeoSnr Network Eng

@Pavan, please share the solution which you have found.....


Thank you so much and appreciate your quick response for every question of mine in the  forum. It's been a pleasure working with you. Your encouragement comes as a gift rather than an option. Thanks again.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial