Avatar of advserver
advserver
Flag for United States of America asked on

Powershell script to remove email address from Exchange 2007 user.

I have Exchange 2007 mailboxes that have been attached to Active Directory user accounts.

The users had mail contacts before attaching the mailboxes.

A script was run to delete the mail contacts, attach the mailboxes, and add the smtp addresses that were found in the mail contact.

There are now two similar addresses in the "email addresses" tab where one needs to be removed.  

The two addresses look like this: "User1@test.internal.com" and "User2@test.internal.com"


I need a script which imports a csv where the user's alias is in one column and the desired email address alias is in the second column.  The script calls the csv and removes the appropriate "@test.internal.com" for the specified users.
PowershellExchange

Avatar of undefined
Last Comment
advserver

8/22/2022 - Mon
Chris Dent


So you have...

Alias,Email
SomeUser,SomeUser@test.internal.com

Is the address specified in the CSV the one you want to keep? Or the one you want to remove? And if it's the one to keep, everything else should be removed?

And you mention both contacts and users here, it makes little difference, but are these users or contacts?

Chris
advserver

ASKER
The contacts are gone and we are left with the Exchange 2k7 mailbox.

The Exchange 2k7 mailbox now has 2 similar email addresses User1@test.internal.com and User2@test.internal.com

User1@test.internal.com represents the address used in the mail contact which was deleted

User2@test.internal.com represents the address set by default when the Exchange 2k7 mailbox was created.

I need to have the User2@test.internal.com deleted for every user specified in a csv file.

"User2" is the alias of the user which would have to be called in the csv and as the user has two emails that end with "@test.internal.com" the full email address would probably have to be in the csv as well.


I know it's a random request but thank you for your time!
advserver

ASKER
I still wasn't that clear.


User2 = Exch2k7 Mailbox

Email addresses for User2: User2@internal.test.com, User1@internal.test.com

Need to have every specified user's alias email address deleted  ie: User2@internal.test.com deleted

Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
ASKER CERTIFIED SOLUTION
advserver

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.