Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

change the text color in html using powershell

I’m confused on how to change the color of the text without using Write-Host and the color should be change in the HTML output.

green

$overallStatus = ''
    
    
    if(($isDBConnected.Equals('Connected Successfully')) -and ($isCMConnected.Equals('Connected Successfully'))){
    $overallStatus = 'GREEN'
    }
    else{
      $overallStatus = 'Red'
       $overallStatus
       }
   

and this is my composition for html

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

for($a=0; $a -le $notiftemplate.Length; $a++){
  
     switch -Regex ($notiftemplate[$a]){ 
         "\[status\]"{
         $notiftemplate[$a] = $notiftemplate[$a] -replace "\[status\]",$overallStatus
         break;
         } 
    }
     

I’m trying to add this on first code

 $overallStatus = @{"<td style='padding-left:5pt;'> <b> [status] </b></td>"}

but it’s not working.

>Solution :

Try this if your code have the right syntax and you don’t use tables in html and there is no more code because of the TD tag:

 $overallStatus = @"<span style='padding-left:5pt;color:green;font-weight:bold;'> GREEN </span>"@

or

 $overallStatus = '<span style="color:green;">GREEN</span>'

If there is more code for the table, because of the td tag use:

 $overallStatus = @"<td style='padding-left:5pt;color:green;font-weight:bold;'> GREEN </td>"@
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading