In Office 365 we've added a domain alias which we'd like to automatically add user email aliases for. I understand we can script this task to add the email domain alias to all existing users, but it would be preferred to automatically assign a email domain alias to all new users on creation to prevent someone forgetting to do this in future. Is this possible?
Alternatively, is it possible to set up some Exchange Admin Center rule that would automatically forward an email domain alias to the primary domain equivalent, thus removing the need for email aliases on each user account?
Adding New Email Addresses for Multiple Mailbox Users by Paul Cunningham pretty much covers this subject.
You should be able create a Email Address Policy in O365 using the *-EmailAddressPolicy (new, get, set, remove etc.) This will allow you to define how email addresses are assigned to users that have this policy enabled.
The technet article shows that it is supported in Exchange Online. https://technet.microsoft.com/en-us/library/aa996800(v=exchg.160).aspx
Here's more info about Email Address Policies. https://technet.microsoft.com/en-us/library/bb232171(v=exchg.160).aspx
I would recommend looking at your default policy and potentially adjusting that. Get-EmailAddressPolicy | Format-List should show you all the values of the default policy. You're probably most concerned about "EnabledEmailAddressTemplates"
You can edit this to do what you want it to, IE: set-EmailAddressPolicy "Default Policy" -EnabledEmailAddressTemplates "SMTP:@maindomain.com","smtp:@newdomain.com"
Note a couple things: There can only be ONE "SMTP", thats the reply to address You can have as many lowercase "smtp" aliases as you want, assuming the domains are set.
This wont be enabled by default, you will need to flip the "EmailAddressPolicyEnabled" from $false to $true on the mailbox for it to take affect. Also note, if you do this on an existing user, it will honor the policy, so make sure you have tested it!!