I have an issue with some CSS. I’ve been running report scripts, and I’ve been using inline CSS:
$custom = "
body {}
table {}
"
So, I finally wised up, and I planned on using -the -CssUri parameter. I looked at the help and basically I just needed to use the parameter and point it to my CSS:
ConvertTo-Html -InputObject $Object -CssUri “C:\input\Home.css” | out-file C:\Input\Object.html
For whatever reason, it will not work. I first tried it on an some existing CSS that was used inline. I then tried it on some new CSS, where I just wanted to change the background color. When I look at the source, I can see the in the head, and everything looks fine. I would also just write up some HTML with a sentence or two, and point it to the same CSS page, and it would receive the CSS.
I even tried to use the -head parameter and I would point to the CSS:
ConvertTo-Html -InputObject $Object -Head ‘’ | out-file C:\Input\Object.html
Finally, I saw this example on technet (Is it possible to incorporate in my Powershell script CSS as the output is HTML?):
$css = get-content “C:\temp\styles.css”
get-service A* | ConvertTo-Html -head “$css”
I tried that and it works. I do see that it’s basically using an inline stylesheet, because the source does not show a link in the , it shows the CSS, but nothing that I tried worked.
I’m trying this with PowerShell 5.1 on Windows 10. I looked at many examples, and the process seems very easy, but for some reason, it just won’t work. Any ideas?