Cmdlet/Script: Fix IMCEAEX non-delivery reports (NDRs) by adding X500 addresses

I worked on a case recently where we wanted to automate solution 2 in this knowledge article:

IMCEAEX non-delivery report when you send email messages to an internal user in Office 365 dedicated

I started with a script but decided to turn it into a cmdlet for easier reuse and elegance. Here's how to use the cmdlet:

  1. Start Exchange Management Shell.
  2. Dot-source the ps1 file so the cmdlet becomes a part of your shell: . c:\temp\Fix-IMCEAEX-NDR.ps1
  3. You can even get help on the cmdlet: Get-Help Fix-IMCEAEX-NDR -full
  4. Create a CSV file with two column headers: IMCEAEX and Account. Each line after should represent an account you want to fix.
  5. Run the command to generate a list of commands: Fix-IMCEAEX-NDR -csvFile "c:\temp\NDRs.csv" | Out-File commands.ps1
  6. Review the generated commands inside the outputted commands.ps1 file using a text editor like Notepad and edit them if necessary.
  7. Run the commands one-by-one by copying and pasting into EMS, or all of them at once by running the ps1 file.

Some information on "cleaning up" the IMCEAEX address: if your address has other escaped characters of the format +HH, simply look up the two characters after the + symbol in the ASCII table and find the HEX match. For example, +21 represents an exclamation point (!).

Hope this helps,