The specified mailbox isn’t unique

I’m having an issue getting mailbox statistics in multi tenant Office 365.

I say multi-tenant, we have several e-mail domains and some users have mailboxes in more than one domain.

Get-mailboxstatistics bombs with the error “The specified mailbox isn’t unique.” on the users with more than one mailboxMailboxNotUniqueI started looking into this issue for the first user “Molly Mayo”

In my case, all of my users were created by CloudMigrator365 as part of the migration, so I know which attributes have been populated.

I have looked at all of the attributes that are not unique, such as FirstName, LastName, DisplayName on the user objectMSOLUserMollyMayo

I also looked at the DisplayName and Alias on the mailbox

MailboxMollyMayo

The biggest issue is the Alias attribute.

When two mailboxes have the same alias, the get-mailboxstatistics command can’t differentiate between them.

No matter which attribute I use to generate a list of objects, for example even if the Name attribute is unique, when I pass this along the pipe, the get-mailboxstatistics command still generates the error.

GetMailStatsNameIf you create a mailbox via the GUI, you get a helpful warning.

HelpfulWarning

However if you script the creation as we do with CloudMigrator365, this warning isn’t visible and unhelpfully you can still create these duplicate aliases.

Changing the alias is a simple step, and it is possible to retain the Primary SMTP Address, User ID and login name.

You can then use this alias to get the mailbox stats, which I suspect is what Powershell is hardcoded to use in the background as an identity.

StatsAlias

Even at this, the mailboxes still share enough information such as DisplayName that you need the extra filtering in PowerShell.

If I don’t include $_.alias, I can find one of the two mailboxes but PowerShell still gets confused about the second one, probably because the DisplayName is not unique.

StatsNoAlias

I played with this a bit, but it doesn’t get much simpler.

Even changing the display name, so that I have two unique mailboxes:

TwoUniqueMailboxes

when I try to get statistics the pipe gets confused and gives me results for the same mailbox twice.

SameMailboxTwice

The only way to select the individual mailboxes it seems is to use get-mailbox | %{get-mailboxstatistics $_.alias} where every mailbox has a unique alias, and as such it doesn’t seem worthwhile changing the display name.

 

 

 

2 Replies to “The specified mailbox isn’t unique”

  1. interesting you got two mailboxes in there in the first place……and the scripting allows it in the first place.

    Only you !!!

Comments are closed.