Useful Powershell script to resolve the X500 address

Mohammed HamadaAzure / Office 365 Integration engineer
CERTIFIED EXPERT
I am a senior IT consultant for Azure, Telecom, Messaging and collaboration and Infra. I have been in the IT sector since 15 years.
Published:
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

1
1,076 Views
Mohammed HamadaAzure / Office 365 Integration engineer
CERTIFIED EXPERT
I am a senior IT consultant for Azure, Telecom, Messaging and collaboration and Infra. I have been in the IT sector since 15 years.

Comments (0)

Have a question about something in this article? You can receive help directly from the article author. Sign up for a free trial to get started.