Posts

Showing posts from March, 2009

Convertto-html, firefox, chrome, CSS rendering problem

Image
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/ th

New Powershell VMWare Summary Report Script using functions

Image
UPDATED and Optimized Script can be found HERE. I'm hoping this is easier to read for any interested. Things I track in this script are as follows: Cluster Name # of Effective Cluster Hosts # of VM's in the cluster # of allocated vCPU's VMWare supported maximum of vCPU's per core Datastore full size Datastore free space Datastore used space as a percentage Above is an example pic of what the script generates and how it should look. The script is posted here . I suggest copying and pasting into a Powershell editor like PowerGUI or Powershell PLUS for readability. It automatically generates an html and stylesheet file and places them on your C drive. You can change a bunch of variables that are commented toward the top of the script. Hope you can find this useful. [Update: I've added sort capability to the code via a Javascript library which can be downloaded here . ]

Powershell html formatting using convertto-html cmdlet

This was took me a little bit to figure out, but I finally did. Wasn't able to find this solution on the web so I figure I would post what I had to do to make it work. I basically had a 'if else' statement that I wanted the return of an if statement to highlight in red and be bolded in html. Unfortunately, the convertto-html cmdlet converts '<' and '>' to html friendly formats for display like '&lt;'and '&gt;'. So here is the key: ...code... Convertto-Html foreach {$_.replace("&lt;","<").replace("&gt;",">")} Afterwards, you can pipe to a file where the formatting you placed in your code stays intact.