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
https://github.com/VikasSukhija/Downloads/blob/master/legacydn.zip
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
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 🙂
Thx..will definitely Create..