Solved

Exporting legacydn - importing X500 address

Posted on 2014-04-06
11
4,464 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
Transaction Monitoring Vs. Real User Monitoring

Synthetic Transaction Monitoring Vs. Real User Monitoring: When To Use Each Approach? In this article, we will discuss two major monitoring approaches: Synthetic Transaction and Real User Monitoring.

 
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

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

Unified and professional email signatures help maintain a consistent company brand image to the outside world. This article shows how to create an email signature in Exchange Server 2010 using a transport rule and how to overcome native limitations …
This article will help to fix the below errors for MS Exchange Server 2013 I. Certificate error "name on the security certificate is invalid or does not match the name of the site" II. Out of Office not working III. Make Internal URLs and Externa…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

688 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