Missing Color in HTML report

Welcome Forums General PowerShell Q&A Missing Color in HTML report

Viewing 4 reply threads
  • Author
    Posts
    • #183759
      Participant
      Topics: 3
      Replies: 2
      Points: 44
      Rank: Member

      Hello everyone,

      I was working on converting ps cmdlets to HTML format with CSS file but the reports don't have colors. The cmdlets are performing successfully but somehow the second cmdlet does not appear with color. When i run the only  "get service" part, CSS works fine. if i run the whole code, it fails.

       $params = @{'As'='Table';
      'PreContent'='
      

      All Services

      '; 'MakeTableDynamic'=$true; 'TableCssClass'='grid'; 'Properties'='Name','DisplayName', @{n='Service Status';e={$_.Status};css={if ($_.Status -eq "Stopped") { 'red' }}; 'Properties'='index','InstanceID', @{n='EntryType';e={$_.Entrytype};css={if ($_.EntryType -eq "Error") { 'red' }}}}} $Services = Get-Service | ConvertTo-EnhancedHTMLFragment @params $eventlog = Get-Eventlog System -newest 25 | ConvertTo-EnhancedHTMLFragment @params2 ConvertTo-EnhancedHTML -HTMLFragments " $services $eventlog " -CssUri C:\Users\A701026\Desktop\sample\style2.css | out-file C:\Users\A701026\Desktop\sample\report2.html  

      here my CSS file.

      ``

      `body {`
      `color:#333333;`
      `font-family:Calibri,Tahoma;`
      `font-size: 10pt;`
      `}`
      `h1 {`
      `text-align:center;`
      `}`
      `h2 {`
      `border-top:1px solid #666666;`
      `}`
      `th {`
      `font-weight:bold;`
      `color:#eeeeee;`
      `background-color:#333333;`
      `cursor:pointer;`
      `}`
      `.odd { background-color:#ffffff; }`
      `.even { background-color:#dddddd; }`

      ````

      `.paginate_enabled_next, .paginate_enabled_previous {`
      `cursor:pointer;`
      `border:1px solid #222222;`
      `background-color:#dddddd;`
      `padding:2px;`
      `margin:4px;`
      `border-radius:2px;`
      `}`
      `.paginate_disabled_previous, .paginate_disabled_next {`
      `color:#666666;`
      `cursor:pointer;`
      `background-color:#dddddd;`
      `padding:2px;`
      `margin:4px;`
      `border-radius:2px;`
      `}`
      `.dataTables_info { margin-bottom:4px; }`
      `.sectionheader { cursor:pointer; }`
      `.sectionheader:hover { color:red; }`
      `.grid { width:100% }`
      `.red {`
      `color:red;`
      `font-weight:bold;`
      `}`

      ``

       

       

       

       

    • #183996
      Participant
      Topics: 3
      Replies: 2
      Points: 44
      Rank: Member

      ++upp

    • #184104
      Participant
      Topics: 0
      Replies: 1
      Points: 8
      Rank: Member

      I had a similar problem and solved it by adding  -Encoding ascii after out-file.

    • #184580
      Participant
      Topics: 6
      Replies: 108
      Points: 301
      Helping Hand
      Rank: Contributor

      There is no $params2 hash table in your posted code. Did you just miss that in the post?

    • #184718
      Participant
      Topics: 3
      Replies: 2
      Points: 44
      Rank: Member

      beside of my syntax mistake,

      adding " @charset "UTF-8"; " to css file solved my issue 🙂

Viewing 4 reply threads
  • You must be logged in to reply to this topic.