I've been searching and testing but so far no joy. In the following script $statFix2 is an important number. I'm trying to figure out how in the html report to change its font to Red if its value is above '10'. I've tried IF statements but not sure where to put it or the correct method. Anyone have an idea?
Thanks!
$smtp = "5.5.5.5"
$to = "[email protected]"
$from = "[email protected]"
$subject = "Replication Status"
$header = @"
<style>
TABLE {border-width: 1px;border-style: solid;border-color: black;border-collapse: collapse;}
TH {border-width: 1px;padding: 3px;border-style: solid;border-color: black;background-color: #B4DFFF;}
TD {border-width: 1px;padding: 3px;border-style: solid;border-color: black;}
</style>
"@
#create report array and foreach loop. This requires a text file with the different consistency group names(case sensitive) in it.
$report = @()
ForEach ($cg in (get-content C:\Scripts\HealthCheckScript\consistencyGroups.txt)){
$tempCgState = (get-content C:\Scripts\HealthCheckScript\cgState.txt)
$tempCgStats = (get-content C:\Scripts\HealthCheckScript\cgStats.txt)
$statFix = $tempCgStats |select-string "WAN traffic"
$statfix1 = $tempCgStats |Select-String "Current image"
$statfix2 = $tempCgStats |Select-String "Journal lag"
$statfix3 = $tempCgState |Select-String "Data Transfer"
$row = "" | Select Consistency_Group, Sync_Status, Transfer_Rate, Journal_Current_Image, Journal_Lag_Status
$row.Consistency_Group = $cg
$row.Sync_Status = $statFix3
$row.Transfer_Rate = $statFix
$row.Journal_Current_Image = $statFix1
$row.Journal_Lag_Status = $statFix2
$report += $row
}
#create Email body using the report and the html style defined above
$body = $report| ConvertTo-HTML -Head $header |out-string
#send the email
Send-MailMessage -SmtpServer $smtp -To $to -From $from -Subject $subject -Body $body -BodyAsHtml
Had to redo the script, but the only solution I have found yet that works is from this thread:
Color-code cells in HTML mail based on criteria