How to get the external email address of a mail user with get-mguser

JayCarper-5747 356 Reputation points
2023-06-13T20:12:20.6066667+00:00

I sync all of my users from on-prem AD to Azure. Some have mailboxes and some are mail users with external email addresses. I can see the external address in Exchange on-prem and Exchange Online, but Get-MGUser frequently returns the user's UserPrincipalName in the Mail field instead of the real email address. And Get-MGUser's ProxyAddresses doesn't list the external address at all.

Is there some other field I can access with Get-MGUser that will give the external email address of a mail user and only the external email address?

Exchange Online
Exchange Online
A Microsoft email and calendaring hosted service.
6,181 questions
Microsoft Security | Microsoft Graph
{count} votes

5 answers

Sort by: Most helpful
  1. Aholic Liang-MSFT 13,886 Reputation points Microsoft External Staff
    2023-06-15T09:56:03.4733333+00:00

     Hi @ Jay Carper ,

    You can use the format-list parameter to view all parameters for a specified user, for example:

    Get-MgUser -UserId ‘27d57b10-ae36-4113-bb27-d8d4dafa4345' |   Format-List
    

    However, my tests show that there are no other parameters to display email addresses other than Mail and UserPrincipalName.

    In addition, I use the Get-MgUser command to get all users, and I can get the following types of recipients , except for mail contacts:

    ·         User mailbox

    ·         Shared mailboxes

    ·         Mail users

    ·         Guest users

    And, the results are compared to guest users in the Exchange admin center, and the email addresses displayed under Mail are their external address.

    2023-6-15-1png

    2023-6-15-2png

    User's image


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment". Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.
    0 comments No comments

  2. Vasil Michev 119.7K Reputation points MVP Volunteer Moderator
    2023-06-14T06:36:35.5333333+00:00

    Check the mail and otherMails properties. But in general, for any Exchange-related objects and properties, you should be using the Exchange Online cmdlets instead.


  3. Aholic Liang-MSFT 13,886 Reputation points Microsoft External Staff
    2023-06-14T08:06:12.3633333+00:00

     

     Hi @ Jay Carper ,

    As Michev says, you can use Exchange Online cmdlets to get the relevant properties of a user mail.

    For example:

    Get-MailUser -Identity "tony" | fl ExternalEmailAddress
    

    In addition, for the get-mguser command, I suggest you can use the Format-List command to get all the relevant parameters to see if there is an external email address.


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment". Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

  4. JayCarper-5747 356 Reputation points
    2023-06-14T13:03:54.9566667+00:00

    I know I can use the Exchange cmdlets to get this information, but it would be a lot more efficient if I could use a single command instead of two, especially since I'll then have to merge the output with custom columns.

    So, back to my original question...

    You can get ProxyAddresses and Mail using Get-MGUser, but it's not returning accurate data. Are there other fields that can be accessed using Get-MGUser that contain the user's real primary/external email address?

    0 comments No comments

  5. JayCarper-5747 356 Reputation points
    2023-09-18T21:41:44.18+00:00

    The problem seems to be related to removing an Exchange license from a user. If you have a synced user with a remote mailbox in Exchange Online, and then you remove the remote mailbox and Exchange license and enable the on-prem user as a mail user with an external email address instead, Azure will change the Mail attribute from the old PrimarySmtpAddress to the MOERA/UPN.

    I have a support request open with Microsoft and they've been trying to figure it out for almost a month now.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.