Released: PelNet
Published Apr 30 2014 08:30 AM 28.6K Views

To download the PelNet script, see the attachment to this blog post.

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 (test@fromdomain.com)
  • Rcpt: Recipient Address (target@targetdomain.com)
  • 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.

Requirements

  1. 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.
  2. 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 test@domain.com -Rcpt user@contoso.com –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 test@domain.com -Rcpt user@contoso.com –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 test@domain.com -Rcpt user@contoso.com –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 test@domain.com -Rcpt user@contoso.com

Test all source transport servers against all smarthosts in a sendconnector.

.\PelNet.ps1 –From test@domain.com -Rcpt user@contoso.com –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 test@domain.com -Rcpt user@contoso.com –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 test@domain.com -Rcpt user@contoso.com –addressSpace contoso.com –sourceTransportServers EX15-01,EX15-02,EX15-03 -mailSubmissionTest

Script Output

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.

Pelnet1

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:

SmartHost,SendConnector,SMTPVerb,Status,TransportServer

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.

End-To-End Example

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 user@targetdomain.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.

PelNet2

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.

PelNet3

Summary

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.

Happy PelNetting…. Smile

Michael Hall
Service Engineer
Office 365

15 Comments
Not applicable
thank you
Not applicable
Thank you Mr. Michael Hall.
Not applicable
Thank You
Not applicable
Great post.. Thanks!!!
Not applicable
Awesome! Thanks!
Not applicable
I can see a few cases where this could come in handy! Thanks for this :)
Not applicable
Thanks
Not applicable
Thanks you Mr.michael hall
Not applicable
Congratulations on another great PowerShell tool for admins..
Not applicable
Nice One Michael.
Not applicable
Hello Michael, This script could be more interactive with colorfull HTML copy of Output which could be used for email purpose.
Thanks,
Sumit Dhuper (MCITP)
Not applicable
Thank you..
Not applicable
Great ! thanks
Not applicable
Excellent. Thanks a lot
Not applicable
Useful!! Thanks
Version history
Last update:
‎Apr 28 2020 02:19 PM
Updated by: