Convertto-html, firefox, chrome, CSS rendering problem

Summary:
To prevent whitespace and/or bloat in your html file use the "-encoding ASCII" switch for the "out-file" cmdlet.

Problem Statement:
I've finally gotten a script to pull a bunch of information then convert it into a fairly clean looking html page. It renders perfectly hosted on IIS with an IE browser pulling CSS and JS for readability and sort capability. The problem is that firefox, chrome, and safari doesn't render the CSS style and JS. Here is the kicker. It's not that the html code, CSS, or JS are bad, but that the html file seems to be bloated w/ white space.

So, powershell generates the html code that should be only equal to 3KB, but the file ends up being double that @ 6KB. So you can literally copy and paste the code into a blank txt doc, convert it to htm, then low and behold, it renders just the same in all browsers. I'm working to figure out how I can clean up this whitespace. So far, just grabbing the file info, w/ the get-content and out-file cmdlet's doesn't seem to work, but I haven't really tried in depth yet.

[Update: All that is needed is the "-encoding ASCII" switch for the out-file cmdlet. I've updated the w/ this info as well script.]

Comments

Anonymous said…
Thank you for posting this Gotcha!
Thought first NoScript is the evil part :-)
JWise1203 said…
Ran into this exact problem. Great solution! Thanks for the blog post.

Popular posts from this blog

NSX-T: vCenter and NSX-T Inventory out of Sync (Hosts in vSphere not showing up in NSX-T)

MacOS: AnyConnect VPN client was unable to successfully verify the IP forwarding table modifications.

vCenter: Cluster Skip Quickstart Workflow via API