Table of Contents
Introduction
In this post I will be sharing a short script that I wrote to generate a user friendly report from MTA-STS reports so that you can easily identify domains that are passing and failing your MTA-STS policy. The idea here is simply to save you some time by just putting the files together and getting a nicely laid out report, instead of having to scour through and pull this information out from many emails manually.
Requirements
There is not much that is required in order to run this script, however there are some things that should be considered.Â
The first is the most obvious, and that is that you would need to have an MTA-STS policy in place (it does not matter if this is in testing or enforced mode) and a reporting mailbox configured in the DNS record in order for you to collect MTA-STS results.
Another thing to consider is that this script will check and try to create folder locations on the root drive of your device (most commonly the C:\ Drive), so you will need to have write access to this in order for this script to complete
Usage
The script itself is fairly straight forward and only Performs 4 key actions being:
- Check for and create required folder locations
- Unzip compressed MTA-STS report files so the content can be accessed
- Pull relevant information from the result files
- Export results from previous step
When you run the script it will tell you which folders it has had to create to proceed. If you have not run this before it will be:
- C:\temp
- C:\temp\MTASTS Report
At this point the script will pause and ask you to move all of the files you want to be included in the report into the ‘C:\temp\MTASTS Report‘ folder. From here you (if you have not already) you will have to download the MTA-STS reports from your reporting mailbox and out them in the aforementioned folder.
Once you have gathered your files and put them in the ‘MTASTS Report’ folder you can press any key on the script to continue. From here it will extract the contents of the files and format the report.
The extracted files are saved within another sub folder (C:\temp\MTASTS Reports\reportfiles) this was done to separate them from the original files in case you need to go back and check them.
Finally the report is then saved to the ‘MTASTS Report’ folder with the filename ‘C:\temp\MTASTS Reports\MTA-STS Report.csv‘
The results will show the following information for each of the result files you placed in the required folder:
- Start-Time:- This is the time this particular host started logging results in that session
- End-Time:- This is the time this host stopped logging results in the session
- Organization Name:- The set name of the organisation using your policy
- Number of successful sessions:- this is the number of sessions that completed communications successfully using your policy withing the current session
- Number of failed sessions:- this is the number of sessions that were unable to complete communications using your policy
The results are saved as a .csv file and therefore do not come in a formatted table so (image below), so if you are planning to hand these results of to another party it would likely be worth a couple of minutes to format a table with the results and save as a .xlsx file.
This should help you highlight exactly what domains and communications are failing with your policy, from there you should be able to determine which domains you will have to look into an find out why they are failing (by going back and checking the results files), or in many cases which domains can just be ignored as they are likely just junk
If you need to run the script a second time you can with relative ease, this only thing that needs to be considered is that you will need to remove the results files from the ‘C:\temp\MTASTS Reports\reportfiles‘ folder in order to prevent them from showing multiple times in the report. You can either choose to leave the original compressed versions in the ‘C:\temp\MTASTS Reports‘ folder if you want to include them in the next report, or remove them if not.
If you are interested in modifying the script to always removing the report files automatically after every run (i.e. just use this for reporting purposes only) then you can enter the following around line 123:
Remove-Item -Path “C:\temp\MTASTS Reports\reportfiles” -Recurse -Force
The Script
Summary
I created this script after having to go through the reports on my first MTA-STS setup and decided I never wanted to do it manually again as it was a tedious task that only got worse as more reports were created.Â
The idea behind this is more to identify what domains are having issues in a quick and efficient manner so that yourself or someone you pass this onto can better decide what needs to be looked into.
Author: Curtis Cannon
My name is Curtis, I am a service engineer for an MSP. My focus is on specialising on Azure/Entra ID and other related cloud technologies found in the Microsoft 365 Suite. This content has been written from my own knowledge on the subject in question, and any opinions given throughout the post are mine and do not represent the opinion of others.
Related Posts
Generate a Device Compliance Report Using PowerShell
In this post I will share a script I have created to generate a report of all managed devices compliance status which will help give you an understanding of which devices need remediating, removing, or have their policies adjusted.
Identify Unassigned Intune Policies with PowerShell
In this post I will share a script I have created to report on all unassigned applications in Intune
Generate Authentication Methods report with a MS Graph Powershell Script
In this post I will share a script I wrote used to generate a user friendly report to display configured Authentication methods for users in Microsoft 365 using the Graph PowerShell Module. This makes identifying what methods are being used...
