How to convert secondary email address (alias) in Office 365 to shared mailbox using Powershell

I know there's a 30 day recycle bin when you delete a user's mailbox. The situation I have is this: user was originally set up with a mailbox using as UPN and primary mailbox. Not realizing the use case for their name in another domain would require configuring it as a shared mailbox instead of an alias, the user got a secondary mailbox with domain. After trying to delete the secondary address and creating a shared mailbox with the same name, it was obvious that the 30 day recycle bin effect was happening.

Before the knee jerk answer of "delete the mailbox and start over" - this is the president of the company and they already have mail activity in the newly migrated Office 365 environment, so we're NOT deleting the whole user.

I've found the samples online of where people delete user mailboxes from the recycle bin using PowerShell. What I'm looking for, since I'm very new at PS, is the language, if it exists, to accomplish the same thing with the secondary addresses of people who actually need that secondary address converted to a shared mailbox. I know there's a convert command for a mailbox which would convert the user's primary mailbox (not just the address), but I'm hoping to either convert the additional email address or delete the additional email address, remove it from the recycle bin immediately, and then create a shared mailbox without the 30 day waiting period.

I tried renaming the secondary once also, but I still got the error message about trying to create a shared mailbox that had a "proxy address already being used" . Any ideas how to accomplish this?
Shannon MollenhauerProject Manager, Senior Technical TrainerAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

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.

Shannon MollenhauerProject Manager, Senior Technical TrainerAuthor Commented:
Another curiosity which may explain why this is such a problem:

I tried creating a shared mailbox with a different name for and when I looked at the email addresses for this mailbox, it also created a secondary for (my default domain). I tried to delete the address but when I hit save, it still appeared in the addresses for the mailbox.

Is this going to be a problem for everything where I might have a user mailbox in my default domain and a shared mailbox in another domain trying to use the same "user" prefix? Any way to avoid this other than changing my default domain back to the domain?
Vasil Michev (MVP)Commented:
But you already have 2 user accounts for him, as you cannot have more than 1 mailbox associated with the same user object. So you will be pretty safe to delete it.

Anyway, best thing to do is to confirm to which object the alias is currently attached. This can easily be done via the following cmdlet:


Open in new window

After you locate the object, you can decide what to do with it. Removing only the alias is the safest option.
Shannon MollenhauerProject Manager, Senior Technical TrainerAuthor Commented:
Perhaps I need to clarify the account situation. We have multiple domains under the same Office 365 tenant structure, but the domains are technically two separate entities, just managed as sister companies, so upper management have accounts in both domains. They need to be able to send email using the second company domain addresses and signatures so we should not have created aliases with the second domain names but rather just shared mailboxes.

But, this problem of the shared mailboxes for the second domains also getting automatic assignments with a secondary address using the default domain makes me think the whole process is hosed.

The get-recipient command returned the same name for both domains, as I would expect, since I put the secondary alias back on for now so the president gets email from that company as well until I figure this out. It reported RecipientType as UserMailbox for both, too.

Is script that will remove the extra address assignment and also remove it from the recycle bin right away so the secondary domain's shared mailbox can be created?
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

Vasil Michev (MVP)Commented:
While you can create a shared mailbox with a different primary smtp address, it will indeed have an alias associated with the default domain added as well. You can remove that after creation or in bulk later via PowerShell. You do not need to delete the recipient object. Once the alias is removed, you can immediately assign it to another existing object, or create a new one.
Shannon MollenhauerProject Manager, Senior Technical TrainerAuthor Commented:
Each time I have tried to delete the alias associated with the default domain it re-appeared in the admin interface. Do you have a sample PS command I can try?
Vasil Michev (MVP)Commented:
Try this:

Set-Mailbox shared -EmailAddresses @{Remove=""}

Open in new window

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
Shannon MollenhauerProject Manager, Senior Technical TrainerAuthor Commented:
I used a new-mailbox command to create a shared mailbox and used Vasil's set-mailbox code to remove the proxy addresses from the users and the arbitrary shared primary domain configuration. PowerShell is appropriately named - Powerful but a tough shell to crack! Thankfully, PS can do things the web interface can't or won't let 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
Office 365

From novice to tech pro — start learning today.