question

MattHolko-0316 avatar image
0 Votes"
MattHolko-0316 asked KyleXu-MSFT commented

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

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.

office-exchange-online-itprooffice-exchange-hybrid-itproazure-ad-tenant
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@MattHolko-0316
I am writing here to confirm with you any update about this thread now?
If the suggestion below helps, please be free to accept it as an answer for helping more people.

0 Votes 0 ·
CristianSPIRIDON72 avatar image
0 Votes"
CristianSPIRIDON72 answered

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


5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

KyleXu-MSFT avatar image
0 Votes"
KyleXu-MSFT answered

@MattHolko-0316

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.



5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.