Migrating old tenant users & groups to other tenant look for conflicts

Matt Holko 1 Reputation point
2021-10-21T00:18:28.993+00:00

My work has purchased another business that has an Office 365 tenant. I want to migrate those user and groups etc over to our current Office 365 tenant. Before doing that I need to compare UPN, email addresses etc for conflicts. For example, we would currently have an accounting@business1.com and the other tenant may have accounting@business2.com
When bringing that over I will need to rename the one we are migrating from to example usa.accounting@business1.com

Is there a way to easily compare these for conflicts before hand? We have thousands and thousands of groups so I can't go through manually and check off that many groups and names. I think I would be there forever.
Does anyone know an easy way to do this? Is there a program out there or something else that could help?

Appreciate your responses.

Microsoft Exchange Online Management
Microsoft Exchange Online Management
Microsoft Exchange Online: A Microsoft email and calendaring hosted service.Management: The act or process of organizing, handling, directing or controlling something.
4,190 questions
Microsoft Exchange Hybrid Management
Microsoft Exchange Hybrid Management
Microsoft Exchange: Microsoft messaging and collaboration software.Hybrid Management: Organizing, handling, directing or controlling hybrid deployments.
1,895 questions
Microsoft Entra ID
Microsoft Entra ID
A Microsoft Entra identity service that provides identity management and access control capabilities. Replaces Azure Active Directory.
19,559 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Cristian SPIRIDON 4,471 Reputation points
    2021-10-21T05:17:46.273+00:00

    Hi,

    You can use powershell Az module to create a powershell script.

    Get-AzADUser will give you all users in a particular tenant and then you can compare in whatever way you want.

    Hope this helps

    0 comments No comments

  2. KyleXu-MSFT 26,211 Reputation points
    2021-10-21T06:03:39.29+00:00

    @Matt Holko

    Connect to the purchased tenant, run commands below on it(Those two files will be used to compare on the new tenant):

    Get-Mailbox -RecipientTypeDetails UserMailbox -ResultSize unlimited | select PrimarySmtpAddress |  Export-Csv c:/temp/users.csv -NoTypeInformation  
      
    Get-DistributionGroup -ResultSize unlimited | select PrimarySmtpAddress |  Export-Csv c:/temp/groups.csv -NoTypeInformation  
    

    Connect to new tenant, then run script below on it(Save script blow into a .PS1 file):
    Compare mailboxes:

    $users = Import-Csv c:/temp/users.csv  
      
    foreach ($user in $users){  
        $temp = $user.PrimarySmtpAddress.Split('@')[0]  
        If(Get-Mailbox $temp -erroraction 'silentlycontinue'){  
            Write-Host $temp "exist in this tenant"  
        }  
    }  
    

    Compare groups:

    $users = Import-Csv c:/temp/Groups.csv  
      
    foreach ($user in $users){  
        $temp = $user.PrimarySmtpAddress.Split('@')[0]  
        If(Get-DistributionGroup  $temp -erroraction 'silentlycontinue'){  
            Write-Host $temp "exist in this tenant"  
        }  
    }  
    

    If there exist a mailbox or group using the same prefix for email address, you will get a result like below:

    142248-qa-kyle-13-57-31.png


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


    0 comments No comments