HTML/CSS Help with Powershell Scripts

So my code looks like this. My question is I’m trying to find a way to add color highlights to certain cells. So for example in the Test-MemoryUsage function the script will produce information about the server printing out the Total Size and the Percent Free. I would like to able to add a style where if the Percent free is less than a number then it will highlight more so red and if it is in good standing then it will highlight green.

function Get-DataSheet{
     [CmdletBinding()]
    param (
            
            )
	
    Begin{}

	Process{
                 $frag5 = Test-MemoryUsage | convertto-html -Fragment -PreContent '

Memory Usage

' | Out-String $head = @' <style> body { background-color:#dddddd; font-family:Tahoma; font-size:12pt; } td, th { border:1px solid black; border-collapse:collapse; } th { color:white; background-color:black; } table, tr, td, th { padding: 2px; margin: 0px } table { margin-left:50px; } </style> '@ convertto-html -head $head -PostContent $frag1,$frag2,$frag3,$frag4,$frag5,$frag6,$frag7,$frag8,$frag9 -PreContent '

Data Collection Sheet

' | out-file C:\Data.html Invoke-Item "C:\Data.html" #Open the document. } End{} }

When you start getting beyond basic HTML + CSS using ConvertTo-HTML, you’ll need to do a loop and manually generate the html code adding style tags or another options is using some fun methods like this:

https://stackoverflow.com/questions/4559233/technique-for-selectively-formatting-data-in-a-powershell-pipeline-and-output-as/4617379#4617379