Each entity I interact with gets its own custom email address that represents me.

It surprises some people – I’ll hear, “Why is your email address (mystorename) at epicminds.com? You must really love shopping here.” I explain to them because I only ever use this email address to interact with you, I know if this email address is stolen or sold. If I begin to receive spam on this email address I can always turn it off. It’s an approach I have used for more than 10 years.

Often email providers do not permit wildcard email addresses (like a catch all – if I don’t see that email address send it to another mailbox) as it enables more spam. So, in shopping for an email host, I needed one that would support unlimited aliases and an easy way to turn them on and off – Office365 supports that functionality through their admin center and through PowerShell.

To keep it simple, I have two PowerShell scripts that add and remove aliases from my account. I share them below, however they need modification to the default mailbox and domain name.

Add Alias

The script below, saved in Add-Alias.ps1, gets the Set-Mailbox command from Office 365 and invokes it with the supplied credentials, adding the alias to the mailbox specified in the parameters. If an @ does not exist in the alias, it appends the default domain name, again specified in the parameters.

Rm Alias

The script below, saved in Rm-Alias.ps1, gets the Set-Mailbox command from Office 365, if it doesn’t exist in the environment and invokes it with the supplied credentials, removing the alias from the mailbox specified in the parameters. If an @ does not exist in the alias, it appends the default domain name, again specified in the parameters. Note this script could be fashioned very similar to the above script, changing only the last line, but is presented in this style to permit easy (and unsafe) embedding of username and password in the script.

Below is a screen capture of a successful adding and removal of a test alias.

Output