Solved

Exporting legacydn - importing X500 address

Posted on 2014-04-06
11
4,282 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
11 Comments
 
LVL 11

Expert Comment

by:Tej Pratap Shukla ~Dexter
ID: 39982409
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
ID: 39983247
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
ID: 39991121
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 11

Expert Comment

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

Author Comment

by:webox_suuport
ID: 39997201
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
ID: 39998243
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
ID: 40025695
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
ID: 40044342
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
ID: 40050305
You Rock!!
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

MS Outlook is a world-class email client application that is mainly used for e-communication globally.  In this article, we will discuss the basic idea about MS Outlook, its advanced features, and types of MS Outlook File formats.
Article by: Dermot
The life of crime is over for 22 year-old Christian Ian Salvador, a student from Isabela State University in the Philippines.
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…
This video discusses moving either the default database or any database to a new volume.

726 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