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.

Comments

Anonymous said…
Thanks a lot..!! I had the same issue and your solution worked well..!!!

Popular posts from this blog

NSX-T: Release associated invalid node ID from certificate

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.