ConvertTo-HTML inserts empty table tag

This topic contains 1 reply, has 2 voices, and was last updated by Profile photo of Don Jones Don Jones 3 years, 8 months ago.

  • Author
    Posts
  • #9656
    Profile photo of davidski
    davidski
    Participant

    When using ConvertTo-HTML with no input object and only -body and -head tags, the output contains a trailing set of empty

    tags. This causes some minor graphical glitching when emailing the contents via Outlook. Apart from dumping the output to a string and manually searching/replacing the empty tags, is there an option that will suppress this spurious tag?

    Sample code:

    $a = Get-Process |Convertto-html -fragment
    $b = Get-service |Convertto-html -fragment
    convertto-html -body "$a $b"

    This comes up a lot for me as my usual flow is to build up a report in pieces and then to combine the report segments with CSS via a final ConvertTo-HTML with -body and -head tags for style application.

    David

  • #9657
    Profile photo of Don Jones
    Don Jones
    Keymaster

    There is no option to do so, no. It'd be listed in the command's help if there was. I'd say a workaround might be to pass the string   (non-breaking space) to -InputObject, but I haven't tried that. I often do the same process (and wrote about it in the ebook on HTML reporting), but never ran into the blank table being a problem. It'd certain be easy enough to -replace out. You might also look at the EnhancedHTML module I wrote and see if that works any better for you. It's part of the ebook (go to the Newsletter page here for the download).

You must be logged in to reply to this topic.