Powershell send additional table information in email body

It is a script that monitors some IPs on the network and after detecting some consecutive communication failures, an email is sent. The email is correctly sending the IPs with communication problems, but I need to include in the email a list or table with the identification of each IP. Can anybody help me? What change should I make to this part of the script?

I tested some changes but I couldn’t correctly format the table with IPs identification.

Part of the script:

$Data = $Status.Values | Where { $_.'Failed Pings' -eq 5 -or ( ($_.'Failed Pings' -ne 0 -and -not ($_.'Failed Pings' % $Alert))) }
If ($Data)
{ $HTML = $Data | Sort Destination,From | ConvertTo-Html -Head $Header -PreContent "<p>O script de monitoracao detectou falhas de conexao<br></p>" | Out-String

$Ref=
"

REFERENCIAS:

IP Identificacao

172.29.186.100 Mguard EDU 172.29.186.101 EDU OP09 PLC 172.29.186.102 EDU OP09 CP343 172.29.186.108 EDU OP10 PLC 172.29.186.115 EDU OP20 PLC 172.29.186.122 EDU OP30 PLC 172.29.186.128 Test1 172.29.186.129 Test2"

$Body= "$HTML
$Ref "

    Send-MailMessage -To $To -From $From -Subject "Shop Floor Tier 1 - Detectado Problemas de Conexao" -Body $Body -BodyAsHtml -SmtpServer $SMTPServer
    Write-Host "Alert Email Sent!`n"
    Start-Sleep -Seconds 1
}

Email received:

Hello @FredRocha,
If I understood you correctly, you need to add a table/list basically a legend to be able to see the computer names that cannot be reached.
You can try something like this:

$Ref="
<b>REFERENCIAS</b>
<table>
<tr>
<th>IP Address</th>
<th>Computer Name  </th>
</tr>
<tr>
<td>172.29.186.100 </td>
<td> Mguard EDU</td>
</tr>
<tr>
<td>172.29.186.101 </td>
<td>EDU OP09 PLC </td>
</tr>
<tr>
<td>172.29.186.102 </td>
<td> EDU OP09 CP343</td>
</tr>
<tr>
<td>172.29.186.108 </td>
<td> EDU OP10 PLC</td>
</tr>
<tr>
<td>172.29.186.115 </td>
<td> EDU OP20 PLC</td>
</tr>
<tr>
<td> 172.29.186.122</td>
<td> EDU OP30 PLC</td>
</tr>
<tr>
<td> 172.29.186.128</td>
<td> Test1</td>
</tr>
<tr>
<td> 172.29.186.129</td>
<td> Test2</td>
</tr>
</table>
"   

Hope that helps.

I believe he wants a way to resolve the IP in the table to a hostname and include that in the table as well, IE add another column/TH for that.

@tonyd ,
That’s totally makes sense and it was my first thought but based on the code provided it looks like references section is like hardcoded dictionary slapped at the end of email.

Understood. It would get a bit ugly resolving the IP and getting that into the table. Wish I had time to figure it out, but I dont.