<

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x

Exchange 2010/2013 CrossForest group Migration made easy

Published on
3,302 Points
302 Views
Last Modified:
Mohammed Hamada
I am a senior IT consultant for Azure, Telecom, Messaging and collaboration and Infra. I have been in the IT sector since 15 years.
In an Exchange Crossforest migration, the distribution groups can be a very complex operation that would cause loss of time, lots of issues and continued headaches if not solved in a timely manner.

I had to do a similar project so I created a script to ease this process.

In an Exchange Crossforest migration, the distribution groups can be a very painful operation that would cause loss of time, lots of issues and continued headaches if not solved in a timely manner. The migration can be a long and boring process that needs to be as accurate as possible to avoid any issues related to members of the group or/and Group’s Primary SMTP details.


While doing a Crossforest migration, I came through this headache and tried to seek a script that would satisfy my migration’s requirements but the only thing I found is the export Powershell made by Satheshwaran Manoharan.


Export Process:


The script exports all groups and their members from the source forest, but to import there’s no option and I had to write my own script. 


To make use of this script first make sure you that you have migrated the Groups with ADMT in the recommended order otherwise the migration would be problematic. 


  • First: Universal Groups 
  • Second: Global Groups 
  • Third: Domain Local Groups


Once groups are migrated to the target forest you can check how they look like through Exchange management shell and whether they have members added or SMTP address set.



After I checked it apparently shows that group is empty and has no Primary SMTP address associated with it.


Import Process:


In order to add members during the migration since this is a Hybrid/Coexistence migration, not cutover, It took time to migrate users and therefore I had to add non-migrated users in target forest as External Contacts to the Distribution Groups and add migrated users as Mailbox users.


Then after adding the users, I had to set up Primary SMTP addresses for the groups according to the exported CSV file from the Source Forest.



To Import users, I had to set up a CSV file with the following format:


In this format, the Display name, Alias, RecipientType and PrimarySMTPAddress belong to the User object that’s included in the group meanwhile, The Dgroup is the Distribution group’s Alias and DGSMTP is the Group’s Primary SMTP address.



The following script imports groups members to their relative groups


#########################################################################################
# If user type is Usermailbox then it’ll be in Target forest as a Contact #
#########################################################################################
$Users = Import-Csv “C:\Groups\dgs.csv”
Foreach ($User in $Users){
$GroupAlias = $User.Dgroup
$GroupSMTP = $User.DGSMTP
Write-Host “$User.Alias” has been Added to the Group $User.Dgroup -ForegroundColor Green -BackgroundColor Black
if ($User.RecipientType -Match “UserMailbox”){
Add-DistributionGroupMember -Identity $GroupAlias -Member $User.PrimarySMTP -BypassSecurityGroupManagerCheck}}


Fixing Distribution Groups Primary SMTP Address:


Since distribution groups are mostly imported without Primary SMTP address through ADMT then we’ll have to also make sure that we fix this for our groups, but what if the destination forest has similar groups or the SMTP is used already? 


In order to avoid any mistake when associating the Primary SMTP address, I have created a script that would check distribution groups with null value in their primary SMTP Address and copy the SMTP address to these groups avoiding any overwrite or change of the destination Distribution groups.


#########################################################################################
# Setup groups with Primary SMTP Address
#########################################################################################
$Groups = Import-Csv “C:\Groups\Group_test.csv”
Foreach ($Group in $Groups){
$GroupAlias = $Group.dgroup
$GroupSMTP = $Group.DGSMTP
if ((Get-DistributionGroup $GroupAlias | %{$_.PrimarySmtpAddress}) -match “$GroupSMTP”) {
Write-Host Group $GroupAlias already has $GroupSMTP Setup as primary SMTP address -ForegroundColor Yellow -BackgroundColor Red}else{
Set-DistributionGroup -Identity $GroupAlias -PrimarySmtpAddress $GroupSMTP -EmailAddressPolicyEnabled $False
Write-Host Group $GroupAlias has $GroupSMTP Setup as primary SMTP -ForegroundColor Green -BackgroundColor Black }}


The script will check if the groups have primary SMTP matches the one in the CSV file, if it doesn’t it’ll set up the primary SMTP address for that group with green color like in the screenshot below



You can use this script with the same CSV file that you will use for adding members to the groups too, If groups SMTP exists already you’ll get the following error



Hope this can be helpful to whoever is doing Exchange Crossforest Migration


0
Comment
0 Comments

Featured Post

Check Out How Miercom Evaluates Wi-Fi Security!

It's not just about Wi-Fi connectivity anymore. A wireless security breach can cost your business large amounts of time, trouble, and expense. Plus, hear first-hand from Miercom on how WatchGuard's Wi-Fi security stacks up against the competition plus a LIVE demo!

Join & Write a Comment

Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
This video tutorial shows you the steps to go through to set up what I believe to be the best email app on the android platform to read Exchange mail.  Get the app on your phone: The first step is to make sure you have the Samsung Email app on your …

Keep in touch with Experts Exchange

Tech news and trends delivered to your inbox every month