Cross-forest Exchange Migration, notes from the field Part 2, Setting UPN

In the first part of this series I had an overview of
Exchange migration which can be found here.

In the second part of these series I will provide more about
handling the transformation to UPN. When you decide to use e-mail addresses for
your UPN, you will need to make sure that you create the UPN from the used
e-mail address of the user. Although this may seem trivial it may not be.
Generally you will want to create the UPN from user’s alias attribute and the E-mail
domain. However alias attribute is populated only once during the mailbox
creation and administrator can change the mail address of the user after it has
been created. In order to identity these account we need a script to compare
these values. The script will basically do the following:

First read all the mailboxes in the organization and loop on
them. Please note that you will need to put resultsize unlimited parameter to
get the whole picture.

get-mailbox
-resultsize unlimited | foreach{

Then you would need to get the e-mail addresses of the user
inside the loop.

for ($i=0;$i -lt
$_.EmailAddresses.Count; $i++)

Once you have the list, you will go through the list looking
for address prefix SMTP which will give you the Primary SMTP address (Secondary
ones will be given by smtp). Some of the users may have empty Email addresses
so you need to check that condition also

$address =
$_.EmailAddresses[$i]

$a=$address.AddressString.ToString()

if
($address.PrefixString -eq "SMTP" -and $a.length -gt 0 -and $a.indexof("@")
-gt 0)

Now that you have found the address you need to store it to
be used after the loop.

$Primary=$a.substring(0,$a.indexof("@"))

Now lets check if this matches the alias attribute

if
([String]::Compare($_.Alias,$Primary,$True) -ne 0)

You will generally have the necessary plumbing to write the
results into a log file for easy consumption. The complete script can be found
as an attachment to the blog. The script is provided as is without any warranty
so use it at your own risk.

After you have identified these users you will need to
correct the alias attribute according to the primary SMTP address attribute.
The script for this is left as an exercise to the user.

You may be asking why we were so diligent about correcting
the alias attribute instead of setting the attribute through a script. The
reason is simple; writing scripts to touch large number of users requires
careful testing.

 So now we need to do
the following:

- Create
UPN suffixes:
Creating UPN suffixes can easily be done through a single line of PowerShell. See here for more details.

**Populate<br>UPN prefix for each user:** You can use [ADModify](https://admodify.codeplex.com/releases/view/6065) tool to do  
this.

After this tasks your users will be able to use the same
e-mail address as their logon names.

Comments

  • Anonymous
    January 01, 2003
    Hi, Your blog entry says "The complete script can be found as an attachment to the blog" but I don't see that script anywhere.  Is there somewhere I can download it? Thanks, Joel