How to color HTML output rows

Welcome Forums General PowerShell Q&A How to color HTML output rows

This topic contains 0 replies, has 1 voice, and was last updated by  Forums Archives 7 years, 2 months ago.

  • Author
    Posts
  • #5505

    Member
    Points: 0
    Rank: Member

    by biblo45 at 2013-02-04 07:30:25

    Hi all,
    I have following script:
    $a = "

    "
    ##############################
    $logfile = "c:\scripts\dcdiag_all_output.log"
    $allDCs = @("xx","yy","zz")
    foreach ($item in $alldcs)

    {
    Dcdiag.exe /v /s:$item >> $logfile

    #New-Variable "results$item" -force
    #$c = $results + $item

    $Results = New-Object Object
    $Results | Add-Member -Type NoteProperty -Name "ServerName" -Value $item
    #$TestCat = $Null
    Get-Content "C:\scripts\dcdiag_all_output.log" | %{
    Switch -RegEx ($_)
    {
    #"Running" { $TestCat = ($_ -Replace ".*tests on : ").Trim() }
    "Starting" { $TestName = ($_ -Replace ".*Starting test: ").Trim() }
    "passed|failed" { If ($_ -Match "passed") {
    $TestStatus = "Passed"

    } Else
    {
    $TestStatus = "Failed"

    } }
    }

    If ($TestName -ne $Null -And $TestStatus -ne $Null)
    {
    $Results | Add-Member -Name $("$TestName".Trim()) -Value $TestStatus -Type NoteProperty -force
    $TestName = $Null; $TestStatus = $Null
    }
    New-Variable "last$item" -force -Value $results

    }

    }

    $11 = $lastXX| ConvertTo-Html -Fragment
    $22 = $lastYY | ConvertTo-Html -Fragment
    $33 = $lastZZ | ConvertTo-Html -Fragment

    ConvertTo-Html -head $a -Body "$11 $22 $33" -as table | out-file "C:\scripts\final.html"

    Remove-Item C:\scripts\dcdiag_all_output.log

    That script outputs following html output:

    a user uploaded image

    What i want is to mark as red for failed rows. But i could not find a proper way to achieve this. Can somebody point me?
    Thanks.

    by DonJ at 2013-02-04 07:37:36

    You would add a class attribute, such as class="red", to the

    or

    tags. You would then add something like .red { color:red; } to your CSS. In my free ebook on HTML reporting (http://www.powershellbooks.com), I actually provide a function that does this based on an expression, but you can approach it however you like.

The topic ‘How to color HTML output rows’ is closed to new replies.

denizli escort samsun escort muğla escort ataşehir escort kuşadası escort