Import Legacy exchange DN from CSV

Hi Readers,

There can be a situation where you are migrating from another exchange organization & you have to import legacy exchange DN.

This is required so that users does’nt get delivery failure when they reply to old messages or send to cached outlook contacts.

Just extract the script on any server that has exchange management tools installed.

the script will get extracted as below (you can find the sample inside it)

execute the script as below

output will be logged in logs folder.

extract the script from below location

http://gallery.technet.microsoft.com/scriptcenter/Import-Legacy-exchange-DN-e8e8052d

Script code :-

############################################################################################### 
##                                                                                             
##           Author: Vikas Sukhija                                                         
##           Date: 07-10-2012                                                       
##           Description:- This script is used for Migration of mailboxes                      
##           (Importing Legacy DN)                                                              
################################################################################################ 

# Add exchange Shell 

If ((Get-PSSnapin | where {$_.Name -match "Exchange.Management"}) -eq $null) 
{ 
    Add-PSSnapin Microsoft.Exchange.Management.PowerShell.Admin 
} 

# Import CSV file that is populated with user id (email address) & Legacy DN 

$now=Get-Date -format "dd-MMM-yyyy HH:mm" 

# replace : by - 

$now = $now.ToString().Replace(“:”, “-”) 

$data = import-csv $args[0] 

# Loop thru the data from CSV 

foreach ($i in $data) 

{ 

$Log1 = ".\logs\" + "legacyDN" + $now + ".log" 
$lDN = "X500:" 
$legacyDN = $lDN + $i.legacyExchangeDN 
$mailbox = get-mailbox $i.userid 
$mailbox.emailaddresses+=$legacyDN 
$mailbox | set-mailbox 
Write-host "$legacyDN has been added to $mailbox" 
add-content $Log1 "$legacyDN has been added to $mailbox" 

} 

####################################################################################


Regards
Sukhija Vikas
Advertisements

2 thoughts on “Import Legacy exchange DN from CSV

  1. Great Script! Have you got one for bulk creating distribution lists & populating them, if not this would be handy… maybe you could create this as your next script 🙂

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s