Thank you for posting your query on Q&A.
I understand that you are trying to update the Domain name via PowerShell or Graph API and Change the users UPN from ******@abc.com to ******@xyz.com in bulk operation.
To update the domain names, you should have the Global Administrator
role and verified ownership of domain.
You can set or change the domain name from the Microsoft 365 admin center or you can use PowerShell to change the domain name with the below PowerShell cmdlet.
Connect your PowerShell to AzureAD
Verify the existing domains in your tenant using:
Get-MsolDomain
cmdlet gets a list of domains in Azure Active Directory.
To Add a new domain, use
New-MsolDomain
this cmdlet adds a domain to Azure Active Directory. In your case you use following cmdlet New-
MsolDomain -Name xyz.com -Authentication Managed
you must verify the domain before it can be used.
To update the user's principal name, or user ID, of all users in your Azure Active Directory tenant you can use.
Get-MsolUser | ForEach-Object { Set-MsolUserPrincipalName -UserPrincipalName $_.UserPrincipalName -NewUserPrincipalName ($_.UserPrincipalName -replace "abc.com", "xyz.com") }
After successfully completion of the above steps set the new domain as the default domain by using the
Set-MsolDomain -Name xyz.com -IsDefault $true
The other side changing the domain name and user principal name (UPN) of your users in Azure Active Directory may cause some issues with their access and experience of Microsoft 365 services. which as below
Site user ID mismatch in SharePoint Online (SPO), OneDrive for Business (ODB), User information not updated in Team, User sign-in issues, OneDrive sync issues. Please ensure to test these changes in a controlled test environment before applying them in production.
I hope this answer helps! If you have any further questions, please feel free to ask.
https://learn.microsoft.com/en-us/entra/identity/hybrid/connect/howto-troubleshoot-upn-changes
Thanks,
Akhilesh.
Please "Accept the answer" if the information helped you. This will help us and others in the community as well.