Update UPN for B2C users

Sebastian Gedge 1 Reputation point
2021-09-20T17:12:31.68+00:00

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
    2021-09-20T21:20:23.067+00:00

    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.

    Best,
    James

    0 comments No comments

  2. Sebastian Gedge 1 Reputation point
    2021-09-21T06:40:01.153+00:00

    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