Quantcast
Channel: Exchange – Microsoft Technologies Blog
Viewing all articles
Browse latest Browse all 214

Import Legacy exchange DN from CSV

$
0
0

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


Viewing all articles
Browse latest Browse all 214

Trending Articles