Delete secondary smtp address

Hello All,

I need some help to delete a secondary smtp address from users in a specific Exchange database. An email policy was incorrectly applied to this database, which added the secondary address by mistake.

I don't really have any skills with Powershell, so any help would be appreciated.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

If your secondary email address is in format of <mailbox alias> the you can try the following code..
$Mailboxes = Get-Mailbox -Database DB01 -result unlimited
Foreach ($Mailbox in $Mailboxes) {
$Smtp = "$($Mailbox.alias)"
Set-Mailbox $Mailbox.alias -EmailAddresses @{remove=$Smtp}

Open in new window

An alternate method can be found from following article..

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
AmpletrixAuthor Commented:
Thank you Subsun.

That worked great. Fantastic.
I've noticed something else though.
We have two custom attributes for two segregated databases and organizations.
Some of the new mailboxes don't have the custom attributes applied to them, and this may be part of the issues I'm getting.
Would it be possible to apply the attributes to any newly created mailboxes?

More details:
We have three segregated departments: (examples) (Custom Attribute1: Fabrikam) (Custom Attribute2: Contoso) (Custom Attribute3: Voorpullers)

I suspect that, when a new mailbox gets created (via a powershell script), it is created in the fabrikam database, because over 80% of time it is for Fabrikam. It is then moved to the other databases if required, but the custom attributes aren't applied automatically.
Is this something that can be done, and if possible, on s regular schedule?

Thanks for the help.
It is possible to update the attributes based on the database.. you need to schedule a script to check this and update it.. Since this is an additional request, please open a new question so we can work on it..
AmpletrixAuthor Commented:
This was exactly what I was looking for. Thank you.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.