Commands to find duplicate SMTP addresses that every Office 365 Admin Should Know

Ever get that “A user with this name already exists. Use a different name.” error message in Office 365? ugh. If so, here are some PS commands to track that pesky duplicate down:

$Duplicateuser = “user@contoso.com
get-contact -resultsize unlimited | where {$_.WindowsEmailAddress -match “$Duplicateuser”} |ft identity 
get-msoluser -All | where {$_.ProxyAddresses -match “$Duplicateuser”} |select UserPrincipalName
Get-MsolGroup -resultsize unlimited  | where {$_.ProxyAddresses -match “$Duplicateuser”} |ft displayname, emailaddress 
get-mailbox -Result unlimited| where {$_.EmailAddresses -match “$Duplicateuser”} | fl Name, RecipientType, EmailAddresses 
get-DistributionGroup -resultsize unlimited | where {$_.EmailAddresses -match “$Duplicateuser”} | fl Name, EmailAddresses 
get-user -ResultSize Unlimited| where {$_.WindowsEmailAddress -match “$Duplicateuser”} |ft identity
Get-Recipient -ResultSize Unlimited| where {$_.EmailAddresses -match “$DuplicateUser”} | Select -Expand EmailAddresses Aliases

Try them all!

Until next time…