I'm looking to find a way to retrieve all of the MX records listed in a string into a text file.
So far I've got a script that gives me an HTML output from which I've used:
$Records = Get-Content -Path "C:\NETESP\MXRecords\MXRecordsHTML.txt" | Select-String -SimpleMatch -Pattern "MX: "
This results in $Records containing a string of:
<DIV class="well transcript"> 0 nsb.nic.uk 156.154.101.3 NON-AUTH Recieved 2 Referrals ,
rcode= NS: ns.mainnameserver.com,NS: ns2.mainnameserver.com, <BR><BR> 1 ns2.
mainnameserver.com 79.170.43.3 AUTH Recieved 2 Answers , rcode= MX: exchange
=engine01-20052-1.icritical.com/pref=10,MX: exchange=engine02-20052-2.icritical.com/pref=20, <BR><BR></DIV></DIV></DIV></SPAN><TD>mx: </TD>
Is there a way to get the MX records and preferences values into a text file? Depending on which server this is run, there may be anywhere up to 6 MX records.