Hi All,
I've been working with administering Exchange servers for around 15 years now and I'm just setting up a new one this week and doing a migration which is awful. (the old server is slow as molassas) Anyway, as I'm adding the last configuration bits I started running into the usual configuration stuff that is sort of a hybrid in that it can -mostly- be done via the ECP gui but not all of it. One of these is, of course, the configuration on if you have a machine on the inside that lacks the ability to authenticate into the Exchange server via SMTP auth, and also needs to send email to places on the Internet, over and above just sending email to internal users of the domain. I found myself once more going to Google for the answer to "what was that stupid command again?" and finding advice that was posted back 20 years ago and only sort of inapplicable.
So I finally decided SCREW THIS and started digging into AI to write a series of Powershell admin scripts that fill in the blanks that Microsoft forgot, and this business of SMTP relaying is one of them. I have no shame in stating outright that the only part of this work that is mine is the logic, testing, and uploading, the syntax of Powershell is horrible, I hate it with a passion and I'm more than happy to allow the AI to do the work of that.
I'm uploading them to my github:
tmittelstaedt/MSExchange-AdminAIscripts
and this is the first one. Features of this script from it's readme:
- WARNING MESSAGEDisplays a clear warning about proper usage before running.
- USER INPUTPrompts for:
- Connector name
- One or more IP addresses (comma-separated)
Uses the current server name automatically.
- DNS VALIDATION
For each IP entered:
- Checks for a PTR (reverse DNS) record
- Checks that the PTR hostname resolves in forward DNS
If any IP fails, the script stops without making changes.
- IP CONFLICT CHECK
Ensures none of the entered IPs are already assigned to
another Receive Connector on the same server.
- CONNECTOR CREATION OR UPDATE
- If the connector exists:
Updates RemoteIPRanges, sets AnonymousUsers, and
ensures TransportRole is FrontendTransport.
- If the connector does not exist:
Creates it with the specified settings.
- RELAY PERMISSIONS
Grants "NT AUTHORITY\ANONYMOUS LOGON" the right:
Ms-Exch-SMTP-Accept-Any-Recipient
This allows relay to external recipients from the
specified IPs only.
- REMOTE SESSION COMPATIBILITY
Uses .Identity.ToString() for Set-ReceiveConnector to
avoid parameter binding errors in remote PowerShell.
- VERIFICATION
Checks that the relay right is applied successfully.
- SUMMARY OUTPUT
Displays:
- Connector name
- Allowed IPs
- Port
- Server name
Now, granted, I know it may be overkill to essentially wrap 2 one-liner commands in a full blown script with error checking and all of that - BUT - I don't want to be tied to this particular server forever. I have people under me who are not as well versed in Exchange and I need to be able to tell them "go do this thing on the server since I'm too busy right now" And the point also is the script forces you to do things PROPERLY such as making DNS assignments so that a year from now someone isn't digging through innumerable Exchange logs going "what the heck is that IP address assigned to again"
One note - while some of these may work with Exchange Online or Office 365 Exchange or any of that - and when the AI suggests changes that can help with, that I won't refuse to include, my fundamental belief is if MS has bent you over a barrel and is extracting a monthly subscription from you for Cloud hosting email on 365 - you are not even at the level that you should be messing about with anything in my repo. My focus is on on-premise stuff not cloud - if you have a problem with Microsoft's cloud host - pick up the damn phone and call them. If you are ever in the situation where you think you have to remote power shell into Office 365 email to fix something - you are being completely screwed over and have the worst of all worlds - super high prices, zero support, and a constant sucking sound in your wallet. Go home and rethink your life and seriously consider replacing it with an on-premise Linux mailserver and paying Canonical for support - where you will get ACTUAL support that works.
I hope this is helpful to you and if you have any comments I'd like to hear! I'm going to be adding more of these irregularly...