Update UPN for B2C users

Sebastian Gedge 1 Reputation point

Is it possible to change a users UPN in an Azure B2C tenant via powershell?

Microsoft Entra External ID
Microsoft Entra External ID
A modern identity solution for securing access to customer, citizen and partner-facing apps and services. It is the converged platform of Azure AD External Identities B2B and B2C. Replaces Azure Active Directory External Identities.
2,706 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. James Hamil 22,886 Reputation points Microsoft Employee

    Hi @Sebastian Gedge , have you used any articles or documents and are getting stuck? This article here does a good job explaining how to do this. It worked the last time I used it. Please let me know if this works for you. If not I can help you further.


    0 comments No comments

  2. Sebastian Gedge 1 Reputation point

    Hi Hames,

    I have followed similar articles and the first part of method 1 works and i can change the UPN to he .onmicrosoft address but am faced with the following when trying to change the UPN to a @Stuff address in the second command.

    "set-AzureADUser : Error occurred while executing SetUser
    Code: Request_BadRequest
    Message: The domain portion of the userPrincipalName property is invalid. You must use one of the verified domain
    names in your organization.
    RequestId: 160e3284-933b-4803-a9c9-b7a3792219a2
    DateTimeStamp: Tue, 21 Sep 2021 06:35:37 GMT
    Details: PropertyName - userPrincipalName, PropertyErrorCode - InvalidValue
    HttpStatusCode: BadRequest
    HttpStatusDescription: Bad Request
    HttpResponseStatus: Completed
    At line:1 char:1

    • set-AzureADUser -ObjectId ******************** -UserPrincipalName *********@Stuff .com
    • ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    • CategoryInfo : NotSpecified: (:) [Set-AzureADUser], ApiException
    • FullyQualifiedErrorId : Microsoft.Open.AzureAD16.Client.ApiException,Microsoft.Open.AzureAD16.PowerShell.SetUser
    0 comments No comments