HTML Output witch colors

by Jun 25, 2015

Hi there.

I made a little script emailing me the Status of my RAID. It takes a Logfile, cuts some lines into a new textfile and sends it via email to me. Everything working so far.

Now I want to send the Email in HTML with colors, Green for Status "Online or Optimal" and Red for all other Statuses.

I'm able to get the output colored in the console with this Script (see below), but I don't know how to convert this to HTML to set it as message.building:

$content = get-content "D:raid-status.txt"
foreach ($i in $content) {
If($i -Match "Online" -oR $i -like "* Optimal") {
write-host -ForegroundColor green $i
elseif($i -Match "Offline" -oR $i -Match "Failed" -oR $i -Match "Ready" -oR $i -Match "Hot Spare" -oR $i -Match "Sub-optimal" -oR $i -Match "Degraded" -oR $i -Match "Rebuild" -oR $i -Match "Impact" -oR $i -Match "Error") {
write-host -ForegroundColor red $i
else {
write-host -ForegroundColor black $i

Probably this is the complete wrong way to achive my goal, so any help is appreciated 🙂

*edit* Powershell Version is 2.0 on a Windows server 2k8 R2, so an Update is not recommended