Building the Mailbox input file
The mailbox input file can be built by
hand, but the most efficient way is to script it. When building
the mailbox input file make sure that source and target
Distinguished Name (DN) are correct in this file. The target
one isn't required if the mailbox alias is the same in both
orgs, but I have found it is easier to include both the source
and target.
Processing a list of
users
To simplify the creation of the mailbox
input files, I decided to write a script that will read in a
list of user names from a file and build the mailbox input files
for me. I created this script when doing an Exchange 2000 to
Exchange 2000 migration and it is only designed to work with the
Active Directory, so you must be running Exchange 2000 or 5.5
with the ADC configured to replicate Exchange data into the AD.
If you are running NT4 you can do a
directory export in the Exchange 5.5 Admin tool. From this file
you can combine the
Obj-Container
and
Directory Name values to get the DN of each user's
mailbox. This combined value is the same as the
legacyExchangeDN value in the AD for a user. If you are
trying to migrate between two Exchange 5.5 organizations or
sites you will need to do an export from the source and target
Exchange servers and use this data to build your mailbox input
files.
The code below will read a list of
samAccountNames, one per line, from a user.txt file. The
first part of the code opens and creates the required files and
then calls the
BuildExFiles sub for each user in the input file. The
example code included with this article supports two source
Exchange servers and one target server.
Set fs =
CreateObject ("Scripting.FileSystemObject")
Set
objUserList = fs.OpenTextFile ("Users.txt", 1, True)
Set
objMailBoxList = fs.CreateTextFile ("MAILBOXES.TXT", True)
Do While
objUserList.AtEndOfStream <> True
ReadText =
objUserList.ReadLine
BuildExFiles Trim(ReadText)
Loop
The
BuildExFiles sub then looks up each user name in the AD
and retrieves the
legacyExchangeDN in both the source and target domains.
The script then passes the
saMAccountName to the custom
FindObjectPath function, covered later under Supporting functions and subs.
This function searches the AD for an object, based on the search
field and value passed to it, and returns the path on the object
found. The script then reformats the path so it points to a
specific DC. This is important because each DC in the AD might
have different information, due to AD replication latency.
Next, the script gets the
legacyExchangeDN from both the source and target user
accounts.
Now that the script has have the user's
source and target
legacyExchangeDN it saves the data to the mailbox input
file for ExMerge. In the code below the script uses
Chr(9),
TAB, as a separator between the source and target
legacyExchangeDNs. By default, ExMerge assumes the
separator between the source and target DN is a comma, but since
some users might have a comma in their mailbox alias name it is
better to use tab as a separator. The settings required to
change the separator will be covered later in this article.
Sub
BuildExFiles (saMAccountName)
SourceUserPath = FindObjectPath ("samAccountName",saMAccountName,SourcedomainDN)
SourceUserPath = "LDAP://" & SourceDC & "/" & SourceUserPath
TargetUserPath = FindObjectPath ("samAccountName",saMAccountName,TargetdomainDN)
TargetUserPath = "LDAP://" & TargetDC & "/" & TargetUserPath
Set
objSourceUser = GetObject(SourceUserPath)
SourceExchangeDN = objSourceUser.Get("legacyExchangeDN")
Set
objTargetUser = GetObject(TargetUserPath)
TargetExchangeDN = objTargetUser.Get("legacyExchangeDN")
objMailBoxList.WriteLine(SourceExchangeDN
& Chr(9) & TargetExchangeDN)
End Sub
Download the Code
|