How can I change the ProxyAddresses property associated with a guest user using PowerShell

IT Admin 0 Reputation points
2024-06-21T19:04:18.7466667+00:00

Guest users in M365 do not have 365 mail boxes. Emails to guest users are sent to the external email address provided when the guest user is created.

On creation of a guest user the user object has the following properties:

  • Mail = "<user's external email address>"
  • ProxyAddresses = "{SMTP:<user's external email address>}"

However, if a guest user is deleted and subsequently restored the ProxyAddress is not re-created properly with the result that emails sent to the guest user are not directed to the correct external email address. To correct this I need to edit the ProxyAddress property but it seems that it is read-only. As a result it is not possible to properly restore a guest user that has been deleted.

It seems that one of the reasons that the ProxyAddress property is read-only is because it is derived from other properties associated with the user object and specifically the Mail property. However, this property cannot be edited in AzureAD and is managed by ExchangeOnline. Unfortunately, however, guest users are not managed by ExchangeOnline as they do not have 365 mail boxes. So it seems like a catch-22 situation for guest users.

Any help or suggestions would be appreciated. As I need to amend the ProxyAddresses property of hundreds of guest users I am only interested in solutions that can be implemented in PowerShell.

Many thanks,

Conor.

Microsoft 365
Microsoft 365
Formerly Office 365, is a line of subscription services offered by Microsoft which adds to and includes the Microsoft Office product line.
4,214 questions
PowerShell
PowerShell
A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
2,272 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Vasil Michev 99,126 Reputation points MVP
    2024-06-22T16:03:58.1766667+00:00

    You can manage the mail property of a Guest user via both the Graph API or Exchange PowerShell. Here are examples:

    PATCH 
    
    {
        "mail": "user@domain.com"
    }
    

    User's image

    Same, via the Graph SDK for PowerShell:

    $params = @{
    	mail = "user@domain.com"
    }
    
    Update-MgBetaUser -UserId blabla -BodyParameter $params
    

    And via Exchange Online PowerShell (use Get-MailUser to list the id if needed):

    Set-MailUser blabla -ExternalEmailAddress admin@M365x935757.onmicrosoft.com
    
    0 comments No comments