How do I highlight failed result in powershell

Stevolee used Ask the Experts™

I am currently writing some powershell code to list services running on a server, everthing is working I can create an HTML page using "convertto-html" to generate all services running in black. However, I need to output stopped services in orange or red.

I have attached the css code in powershell, I don't want to create the tables manually using HTLM since convertto-html can do the job easily.

I am using the command below to generate the html:
$myColSvc | ConvertTo-Html -head $a body "Service Report" | Out-File -Append $filelocation

$a = "<style>"
$a = $a + "body{color:#FFFFFF;background-color:#1270A6;font-size:10pt;font-family:'trebuchet ms', helvetica, sans-serif;font-weight:normal;padding-:0px;margin:0px;overflow:auto;}"
$a = $a + "a{font-family:Tahoma;color:Orange;Font-Size:10pt display: block;}"
$a = $a + "table,td,th {font-family:Tahoma;color:Black;Font-Size:10pt}"
$a = $a + "th{font-weight:bold;background-color:#CCCCCC;}"
$a = $a + "td {background-color:white;text-align: center}"
$a = $a + "</style>"

Open in new window

Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
This seems more of a powershell question than anything, but what you want is for the 'failed services' to have an html class applied such as <div class="failed_service">Error:...</div> and then in your CSS style, create something like:

    font-weight: bold;
    color: red;


Thanks for the updayte. However, I need to pass the css parameters to "convertto-html" I guess you are right I need an expert on powershell then. Please can anyone with ps skill help resolve....

you have a good tutorial on html formatting with convertto-html here:

it explains Color formatting. Let me know if you havé additional question on this.
This post explains the dame case as yours:

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial