[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More


Useful Powershell script to resolve the X500 address

Published on
3,491 Points
1 Endorsement
Last Modified:
Mohammed Hamada
I am a senior IT consultant for Azure, Telecom, Messaging and collaboration and Infra. I have been in the IT sector since 15 years.
In migration, Powershell can be a very crucial tool to achieve success and finalize projects within deadline or even fix issues.

X500 or Legacy Exchange DN Attribute can cause lots of issue during the migration

During the time of working with Exchange Migration projects, you might face lots of issues with users not being able to send an email to their migrated colleagues due to some issues with contacts which was caused by the Legacy Exchange DN not being migrated with the user or lost due to some wrong deletion.

Once users try to send an email to that particular user with the missing Legacy Exchange DN. The receiving Exchange server will result in an error and send it to the user as NDR message explaining to them that the error is due to not finding the particular address.

The solution to this particular problem is very simple especially if it’s a couple of users however to resolve the address you’ll need to google and understand the language that Exchange server users to match the originally used address in the missing user’s attributes.

The below script would work accordingly with whatever situation that faced me and it became very handy to me.

How to use:

1- Copy the script to a notepad and save as convert.ps1 on Desktop

2- Run the script and try to type in PowerShell convert-X500 then hit enter.

3- Copy and paste the address you got from the error message above.

Once you copy and paste hit enter and you’ll get the final result

Note: Make sure you remove the @domain.local in the end

Function Convert-X500{ # Define the Legacy Exchange DN here
Write-Host ""Enter your X500 Address here..."" -ForegroundColor Green -BackgroundColor Black
 $X500Source  = read-host 

 # Converts the various strings to the proper syntax
 $X500 = $X500Source.Replace("_", "/")
 $X500 = $X500.Replace("+20", " ")
 $X500 = $X500.Replace(“IMCEAEX-", "")
 $X500 = $X500.Replace("+28", "(")
$X500 = $X500.Replace("+29", ")")
 $X500 = $X500.Replace("+2E", ".")
 $X500 = $X500.Replace("+5F", "_")
 $X500 = $X500.Replace("@YourDC.localHere", "")

Write-Host X500:$X500}

Hope you find this helpful


Featured Post

Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

how to add IIS SMTP to handle application/Scanner relays into office 365.
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…

Keep in touch with Experts Exchange

Tech news and trends delivered to your inbox every month