Missing Color in HTML report

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.

[pre] $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 [/pre]

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;`
`}`

``

 

 

 

 

++upp

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

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

beside of my syntax mistake,

adding " @charset “UTF-8”; " to css file solved my issue :slight_smile: