Forum Discussion

  • gteibo1Hi there! 

     

    Your description is a bit vague, lets see if i understood you correctly:

     

    A)

    You have a tenat X and you are NOT going to setup a new tenant but just register a DOMAIN in the existing tenant x and want to change the UPN so that the users receive mail with the new Domain name?

     

    OR

    B)

    You want to physically move mailboxes between Tenants?

     

    Two totally different things here, let me know what you actually want to achieve and am happy to help. Done some 300+ migrations so might be able to help you 🙂

     

    EvilSecurityFellow

    • parsian2's avatar
      parsian2
      Copper Contributor
      EvilSecurityFellow
      A)

      You have a tenat X and you are NOT going to setup a new tenant but just register a DOMAIN in the existing tenant x and want to change the UPN so that the users receive mail with the new Domain name?

      exactly i want to do as you mentioned on point (A)
      • chrisslroth's avatar
        chrisslroth
        Brass Contributor
        Hi gteibo1,
        Change the UPN with Powershell:
        # Define the new UPN suffix
        $newUPNSuffix = "new-domain.com"

        # Connect to Azure AD
        Connect-AzureAD

        # Get all users in Azure AD
        $users = Get-AzureADUser -All $true

        # Loop through each user and update their UPN
        foreach ($user in $users) {
        # Extract the username part from the current UPN
        $username = ($user.UserPrincipalName).Split('@')[0]

        # Construct the new UPN
        $newUPN = "$username@$newUPNSuffix"

        # Set the new UPN
        Set-AzureADUser -ObjectId $user.ObjectId -UserPrincipalName $newUPN
        }

        Write-Host "UPNs have been updated for all users."

        After hat change der primary SMTP address:
        # Define the new primary SMTP domain
        $newPrimarySMTPDomain = "newdomain.com"

        # Get all mailboxes
        $mailboxes = Get-Mailbox -ResultSize Unlimited

        # Loop through each mailbox and update the primary SMTP address
        foreach ($mailbox in $mailboxes) {
        $currentPrimarySMTP = $mailbox.PrimarySmtpAddress
        $newPrimarySMTP = $mailbox.UserPrincipalName.Replace('@', "@$newPrimarySMTPDomain")

        # Set the new primary SMTP address
        Set-Mailbox -Identity $mailbox.Identity -PrimarySmtpAddress $newPrimarySMTP -EmailAddressPolicyEnabled $false

        Write-Host "Changed primary SMTP address for $($mailbox.DisplayName) from $currentPrimarySMTP to $newPrimarySMTP"
        }

        Write-Host "Primary SMTP addresses have been updated for all mailboxes."
    • John1982's avatar
      John1982
      Copper Contributor

      EvilSecurityFellow 

      Hi we are also doing a migration from one Office 365 tenant to another in batches. the UPN is changing because they use firstname.lastname@domain.com

      Source was firstinitial.lastname@domain.com

       

      I have a question about Resource Room Mailboxes. Has anyone dealt with that. 

      Like how to handle Meeting Rooms when you migrating from Office 365 to Office 365 and your domain and upn are changing actually

       

      Thanks

  • Lewis-H's avatar
    Lewis-H
    Iron Contributor
    Migrating existing domains between two Office 365 tenants.
    Step 1: Disable the ADFS Federation. This step only applies to tenants with one or more domains using identity federation.
    Step 2: Disable Azure Active Directory Connect synchronization.
    Step 3: Change all UPNs to the .onmicrosoft.com domain.
    Step 4: Remove any dependency.
    • MoCloudx360's avatar
      MoCloudx360
      Copper Contributor

      Lewis-H That sounds very wrong, why would the OP need to disable federation and ADSYnc, that will break some Integrations

  • There's no need for "migration". All you need to do is change the Primary SMTP address to point to the new domain, as well as any other attributes that make sense for your scenario (UPN for example).

Resources