Solved

Exporting legacydn - importing X500 address

Posted on 2014-04-06
11
3,826 Views
Last Modified: 2014-05-08
Hi Guys,
I'm not a scripting guy so I hope you can help me out with my task.
We are performing migration of 1000 mailboxes from Datacenter A to Datacenter B.
Each DC is with Exchange 2010SP3.

Problem is that I need to lookup for each account own LegacyDN in the first Active Directory and add it to the new account as X500 address.

If either of you can help me with this it will be great.
Basically, I need to have a script that export all the legacyDN of users based on their smtp address (Alias won't work, there are multiple users with the same alias) from the first site, and another script (or command) that will allow me to create X500 addresses to the same users on the new site using the output from the first script.

So, any help here will be very much appreciated.
Thanks.
0
Comment
Question by:webox_suuport
  • 5
  • 3
11 Comments
 
LVL 11

Expert Comment

by:Tej Pratap Shukla ~Dexter
Comment Utility
Hey there
I took help from few internet sources to guide you through this problem, so here’s the powershell script you needed. To export user information from legacy DN execute the following Powershell script
Get-Mailbox -resultsize unlimited | Select-Object displayname -expandproperty emailaddresses | Where-Object {$_.smtpaddress -like "*domain.com*"} | Select-Object displayName,SmtpAddress | Export-csv "C:\details.csv"
We have now updated the details in a csv file named as details.csv. To create X500 addresses you need to execute the following command
$PrevCSV=Import-CSV c:\ details.csv
ForEach($Line in $PrevCSV)
{
$ProxyAddresses=$Line.EmailAddresses -split ";"
$X500Address="X500:"+"$($Line.LegacyExchangeDN)"
$ProxyAddresses+=$X500Address
Set-DistributionGroup -Identity $Line.Name  -EmailAddresses $ProxyAddresses
}
These commands should do the work as per your expectations. Feel free to ask for further queries
Thanks
~Dex
0
 

Author Comment

by:webox_suuport
Comment Utility
Hi Dex,
First of all, thanks a lot.
The first part worked for me, but the I'm having problems with the second part.
I've copied the text to ps1 script and tried to execute it, but got the following error:

[PS] C:\>.\x500.ps1
Import-Csv : Cannot bind parameter 'Delimiter'. Cannot convert value "details.csv" to type "System.Char". Error: "String must be exactly one character long."
At C:\x500.ps1:1 char:20
+ $PrevCSV=Import-CSV <<<<  c:\ details.csv
    + CategoryInfo          : InvalidArgument: (:) [Import-Csv], ParameterBindingException
    + FullyQualifiedErrorId : CannotConvertArgumentNoMessage,Microsoft.PowerShell.Commands.ImportCsvCommand

Cannot bind argument to parameter 'Identity' because it is null.
    + CategoryInfo          : InvalidData: (:) [Set-DistributionGroup], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Set-DistributionGroup

Open in new window


If I'm trying to execute it manually, it ends:
[PS] C:\>ForEach($Line in $PrevCSV)
>> {
>> $ProxyAddresses=$Line.EmailAddresses -split ";"
>> $X500Address="X500:"+"$($Line.LegacyExchangeDN)"
>> $ProxyAddresses+=$X500Address
>> Set-DistributionGroup -Identity $Line.Name  -EmailAddresses $ProxyAddresses
>> }
>>

Open in new window


Probably doing it the wrong way... :-)
0
 

Author Comment

by:webox_suuport
Comment Utility
Hmmm...
Guys? Some assistance here?
I need to migrate on Monday an organization of 250 mailboxes and I'm really really not into editing each account manually.

Edit:
It turns out that the first part is not so good, it does export the email addresses based on the domain, but not exporting the corresponding legacyExchangeDN attribute.
0
 
LVL 11

Expert Comment

by:Tej Pratap Shukla ~Dexter
Comment Utility
Hey
Try enclosing the path in quotes eg.
Import-CSV 'c:\ details.csv'
0
Zoho SalesIQ

Hassle-free live chat software re-imagined for business growth. 2 users, always free.

 

Author Comment

by:webox_suuport
Comment Utility
Hi,
Well I managed to export the details using the following command:
Get-Mailbox -Filter {Emailaddresses -like "*domain.com*"} |select name,displayname,PrimarySmtpAddress,LegacyExchangeDN |Export-Csv "C:\details.csv"

Open in new window


Second part - I have tried to execute your script, but although it completed without any errors, the X500 address wasn't created.
0
 
LVL 11

Expert Comment

by:Tej Pratap Shukla ~Dexter
Comment Utility
Hey
Well the command should have created x500 addresses, as the script executed successfully.Apparently I don't have access to a machine so cannot assist you regarding this issue, still you can try out another script.

"Import-CSV c:\details.csv | foreach{Set-ADuser -identity $_.user -add @{proxyAddresses = "X500:/o=mex05/ou=Exchange Administrative Group/cn=Recipients/cn=$($_.legacy)"}}"

Please revert back as soon as possible.

Thanks
~Dex
0
 

Author Comment

by:webox_suuport
Comment Utility
Hi,
Attaching here is example of the csv that I have.
Running your command fails with Set-ADUser : Cannot validate argument on parameter 'Identity'. The argument is null.
Since I don't have field identity on the csv.

Another point, I can see that your command is adding the X500 with different address that I have.
details.csv
0
 
LVL 37

Accepted Solution

by:
Jamie McKillop earned 500 total points
Comment Utility
Hello,

The following script will do what you want:

Import-Csv C:\details.csv | % {
	$ProxyAddresses = (Get-Mailbox $_.primarysmtpaddress).emailaddresses
	$ProxyAddresses += [Microsoft.Exchange.Data.CustomProxyAddress]("X500:$($_.LegacyExchangeDN)")
	Set-Mailbox $_.primarysmtpaddress -EmailAddresses $ProxyAddresses
}

Open in new window


-JJ
0
 

Author Closing Comment

by:webox_suuport
Comment Utility
You Rock!!
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

It’s a strangely common occurrence that when you send someone their login details for a system, they can’t get in. This article will help you understand why it happens, and what you can do about it.
Learn to move / copy / export exchange contacts to iPhone without using any software. Also see the issues in configuration of exchange with iPhone to migrate contacts.
The purpose of this video is to demonstrate how to set up an account with Mailchimp. This will be demonstrated using a Windows 8 PC. Tools Used are: Mailchimp.com Go to Mailchimp.com : Enter an Email, Username, and Password. Click Create My Acco…
In this Micro Video tutorial you will learn the basics about Database Availability Groups and How to configure one using a live Exchange Server Environment. The video tutorial explains the basics of the Exchange server Database Availability grou…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now