Microsoft - Exchange - PowerShell - Notes

Enable-Mailbox does not work when mailNickname is populated

Scenario
A user account has the mailNickname AD property already populated.
You try to use something similar to the following Enable-Mailbox command to create a mailbox (with or without the -Alias parameter):

Enable-Mailbox -Identity "$strName" `
-Alias $strAlias `
-AddressBookPolicy "$strAddressBookPolicy" `
-Database "$strDatabasePrefix$i"

Error
The following error will appear:

Enable-Mailbox : ExternalEmailAddress is mandatory on MailUser. Property Name: ExternalEmailAddress
At line:13 char:1
+ Enable-Mailbox -Identity "$strName" `
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (0:Int32) [Enable-Mailbox], DataValidationException
    + FullyQualifiedErrorId : 9F3F238C,Microsoft.Exchange.Management.RecipientTasks.EnableMailbox

Fix
Clear the mailNickname attribute on the account and use the -Alias parameter of Enable-Mailbox to set the Alias/mailNickname.