With the huge scale environment I currently work in my team has had some difficulty when it comes to validating customer transport changes, specifically when adding new send connectors or new smart hosts. The same goes for troubleshooting mail flow….you know…whip out good ole’ Telnet, check SMTP status manually and then go on from there. What happens when security bans Telnet? What happens when you have 40 transport servers that you need to validate against 20 – 30 smart hosts over multiple connectors? Or you have a gazillion address spaces over a gazillion send connectors….you need some way of automating the checks to help you with troubleshooting if you need to, or validate a transport change when you make changes to send connectors.
Well, let me introduce a very simple, yet efficient tool I branded PelNet…..yes, that’s my take on PowerShell Telnetting :-)
So, let’s see what this baby can do.
Before I get into the usages, let’s talk about the parameters the script accepts:
- AddressSpace: Which AddressSpace should the script look for in the Send Connectors?
- sendConnector: Specify if you want the scope to be a single Send Connector.
- SourceTransportServers: Accepts comma separated list of transport servers to test from.
- smartHost: The smarthost you want to test against. Accepts comma separated list value.
- mailSubmissionTest: Use this switch if you want the script to submit the mail to the mailbox. If you omit the parameter the script will skip the DATA portion of the SMTP verb.
- From: From address (email@example.com)
- Rcpt: Recipient Address (firstname.lastname@example.org)
- LogFolderPath: Log file and report location, default will be current path if not specified.
- Port: Default is 25, but you can specify a custom port if you need to.
- You need to run this from a machine that has the Exchange management tools installed. Certain parameter combinations don’t require EMS; however, the tool will automatically load the Exchange Server PowerShell snap-in, if it’s required.
- Remote PowerShell needs to be configured so that the script is able to remote execute on the transport servers. See here.
The logic is simple: Depending on what parameters you specify, the script will validate accordingly and give you a nice CSV output that you can use to check the SMTP status codes for each server.
Script Execution Examples
Show the full help with examples
Get-help .\pelnet.ps1 –full
Let’s say you want to test your 50 transport servers against a new smarthost that needs to be added to a send connector soon.
.\PelNet.ps1 -From email@example.com -Rcpt firstname.lastname@example.org –smarthost smarthost.domain.com
Test all source transport servers in all send connectors with a specific address space against a specific smarthost.
.\PelNet.ps1 –addressSpace contoso.com -From email@example.com -Rcpt firstname.lastname@example.org –smarthost smarthost.domain.com
Test all send connectors with a specific address space against a multiple smarthosts on a custom port.
.\PelNet.ps1 –addressSpace contoso.com -From email@example.com -Rcpt firstname.lastname@example.org –smarthost smarthost.domain.com –port 25070
Test every send connector with a specific address space against all the smarthosts in those send connectors.
.\PelNet.ps1 –addressSpace contoso.com -From email@example.com -Rcpt firstname.lastname@example.org
Test all source transport servers against all smarthosts in a sendconnector.
.\PelNet.ps1 –From email@example.com -Rcpt firstname.lastname@example.org –sendConnector Outbound_Contoso
Test a specific address space from all source transport servers to all smarthosts in all send connectors (bear in mind execution time here).
.\PelNet.ps1 –From email@example.com -Rcpt firstname.lastname@example.org –addressSpace contoso.com
Test a specific address space from selected source transport servers to a smarthost and queue the mail for delivery.
.\PelNet.ps1 –From email@example.com -Rcpt firstname.lastname@example.org –addressSpace contoso.com –sourceTransportServers EX15-01,EX15-02,EX15-03 -mailSubmissionTest
Now that we covered the usage examples, let’s chat about the output.
The console output will look similar to the below screenshot. As you can see, this will show you on which transport server the tool is currently invoking the code.
The files that the tool will output is a log file and most importantly a comma separated value (.csv) file that contains the data you can use to get a holistic view of the situation you tested.
The csv file contains the following columns:
Using the values in these columns you can determine if the server is accepting traffic or not. Please note that the SendConnector column depends on the parameters you used.
Let’s take a look at an example. Let’s say I want to test connectivity to all smarthosts for the contoso.com address space in my organization (with a mail submission test).
.\PelNet.ps1 –From Michael.Hall@uclabz.com -Rcpt email@example.com –addressSpace Contoso.com -mailsubmissiontest
Within the BLUEbox you’ll notice the status responses and return string back from the server.
Within the REDbox, if a remote smarthost is not accepting traffic on the port you’re trying to connect to or not reachable, you‘ll get a status and ReturnString value of CONN_ERROR.
Finally in the GREEN box, the mailSubmissionTest switch was used so the tool tried to submit the test message for delivery. No response would be sent from the smarthost during the subject and content portion, thus the columns showing NULL.
It’s easy to filter on any of these columns and determine if you have a connectivity issue. You can also create a pivot table to get an overview of the results.
As you can see, this tool can be very powerful when you need to quickly test mail flow or validate a bunch of servers against a smart host or multiple smart hosts.
I hope this tool will help you, as always I’m open to any feedback or improvements.