Highlight cells of specific text in html file using Powershell

I have a html file with a table in it and I was trying to change the color of the cell based on the cell value like available or unavailable.

Below is the code

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<style>
h1, h5, th { text-align: center; font-family: Segoe UI; }
table { margin: auto; font-family: Segoe UI; box-shadow: 10px 10px 5px #888; border: thin ridge grey; }
th { background: #0046c3; color: #fff; max-width: 400px; padding: 5px 10px; }
td { font-size: 11px; padding: 5px 20px; color: #000; }
tr { background: #b8d1f3; }
tr:nth-child(even) { background: #dae5f4; }
tr:nth-child(odd) { background: #b8d1f3; }
</style> 
</head><body>
<table>
<colgroup><col/><col/></colgroup>
<tr><th>Server</th><th>Status</th></tr>
<tr><td>Server1</td><td>Available</td></tr>
<tr><td>Server2</td><td>Unable to Connect</td></tr>
</table>
</body></html>


can someone help me change the background color of Status column based on it’s value

Since you do not share any code it seems like you did not make an own attempt to get this task done by yourself in the first place.

Here you can get some general help:

I gave an example of how to do this in a previous thread. Take a look here:
ConvertTo-HTML Conditional Formatting

1 Like