Today, I received an email from a customer that one of the scripts I had in the gallery wasn’t working correctly. Yes, I know it’s hard to believe, but I made an update and didn’t regression test completely, and then something stopped working.
What turned out to be the problem? If inquiring minds want to know, please investigate and tell me. The only thing I can determine is that I sent a particular value as an argument to Get-Mailbox, the script would skip it. If I typed it interactively, it worked fine. If I passed the same argument to Get-MailContact or Get-MailUser, it worked fine.
The solution eludes me. But, I have updated the script and tested it against mailboxes, mail contacts, and mail users, and have updated the logging and display output to screen for those moments when you are trying to remove an address pattern and it is set as the primary SMTP address of the object. It will bark at you, since Exchange doesn’t like it. At least, now you’ll have a log that tells you so.
The updated TN gallery script is here: https://gallery.technet.microsoft.com/Remove-Exchange-Proxy-eb5be217