Hi
I have this simple script that reads a file (list of servers) and pings it and outputs if pinging the word up in green is displayed next to server if or down red is displayed
My problem, say in this example there are 6 servers s1,s2….s6 and s3 is not pinging
I have found that
s1/s2 says up in green
s3 says down in red
s4-s6 says up but in red, this is my problem why is the reminder red.
any help would be really appreciate or even a nice way to format this
$MessageParams = @{
From = 'abc@test.com’
To = "recabc@test.com”
subject = "Ping Exchange”
SMTPServer = 'SMTPServer'
}
$report = ""
$ServerName = get-content “.pinglist.txt”
foreach ($Server in $ServerName)
{
if (test-Connection -ComputerName $Server -Count 1 -Quiet )
{ $report += write-output "$Server UP <br>"
} else
{ $report += Write-output "$Server <b><font color=red> Down <br>"
}
}
$report
Send-MailMessage @MessageParams -building $report -bodyashtml -Priority high