{"id":3966,"date":"2014-08-22T11:55:21","date_gmt":"2014-08-22T15:55:21","guid":{"rendered":"http:\/\/jdhitsolutions.com\/blog\/?p=3966"},"modified":"2014-08-29T14:15:30","modified_gmt":"2014-08-29T18:15:30","slug":"friday-fun-text-to-html","status":"publish","type":"post","link":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3966\/friday-fun-text-to-html\/","title":{"rendered":"Friday Fun Text to HTML"},"content":{"rendered":"<p><a href=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/08\/html.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignleft size-thumbnail wp-image-3967\" src=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/08\/html-150x150.jpg\" alt=\"html\" width=\"150\" height=\"150\" \/><\/a>I love being able to create HTML documents from PowerShell commands. The Convertto-HTML cmdlet will happily turn any object into an HTML table using whatever properties you specify. Plus you can do all sorts of fancy things such as embedding a style sheet in the header, creating HTML fragments and inserting additional HTML elements. Today's Friday Fun takes ConvertTo-HTML a bit further. As always what I have isn't necessarily a production-worthy script but hopefully it will serve as a learning tool.<\/p>\n<p>My idea was to take a text file such as a script and turn it into an HTML document using alternate shaded rows for the style. I already had a style header from some other scripts so that part was easy.  My first attempt was to simply get the content of the file and convert to HTML. <\/p>\n<pre class=\"lang:ps decode:true \" >get-content .\\XMLDemo.txt | convertto-html<\/pre>\n<p>But there is a problem which you'll see if you try this at home. ConvertTo-HTML is looking for a set of object properties, and the the contents of a file don't have any. Or to put it another way, I need to turn the contents of the file into an object. Since I knew I wanted to include the line number, I figured I could use the [pscustomobject] type that was introduced in PowerShell 3.0.<\/p>\n<pre class=\"lang:ps decode:true \" >get-content .\\XMLDemo.txt | foreach -begin {$i=0} -process { \r\n#create a custom object out of each line of text\r\n$i++\r\n[pscustomobject]@{Line=$i;\" \"=$_}\r\n} <\/pre>\n<p>When run, I each line is turned into a custom object with a property for the Line number and a property for the value of each line. Normally, you would want to give your property a name, but in this case I don't want a property name so I'm using a blank. You'll see why eventually. Now I can pipe this to ConvertTo-HTML and get the output I'm expecting. That's the crux of the script. Here's the complete function, ConvertTo-HTMLListing<\/p>\n<pre class=\"lang:ps decode:true \" >#requires -version 3.0\r\n\r\nFunction ConvertTo-HTMLListing {\r\n\r\n&lt;#\r\n.Synopsis\r\nConvert text file to HTML listing\r\n.Description\r\nThis command will take the contents of a text file and create an HTML document complete with line numbers.\r\n\r\nThere are options to suppress the line numbers and to skip any blank lines. The command is intended to convert one file at a time although you can pipe a file name to the command.\r\n.Example\r\nPS C:\\&gt; ConvertTo-HTMLListing -path c:\\scripts\\myscript.ps1 | out-file d:\\MyScript.htm\r\n.Example\r\nPS C:\\&gt; dir c:\\work\\myfile.ps1 | ConvertTo-HTMLListing | Out-file d:\\myfile.htm\r\n.Example\r\nPS C:\\&gt; foreach ($file in (dir c:\\work\\*.txt)) { ConvertTo-HTMLListing $file.fullname | Out-File D:\\$($File.basename).htm }\r\n\r\nCreate an HTML file for each text file in C:\\work.\r\n.Notes\r\nLast Updated: 8\/22\/2014\r\nVersion     : 0.9\r\n\r\nLearn more:\r\n PowerShell in Depth: An Administrator's Guide (http:\/\/www.manning.com\/jones6\/)\r\n PowerShell Deep Dives (http:\/\/manning.com\/hicks\/)\r\n Learn PowerShell in a Month of Lunches (http:\/\/manning.com\/jones3\/)\r\n Learn PowerShell Toolmaking in a Month of Lunches (http:\/\/manning.com\/jones4\/)\r\n \r\n  ****************************************************************\r\n  * DO NOT USE IN A PRODUCTION ENVIRONMENT UNTIL YOU HAVE TESTED *\r\n  * THOROUGHLY IN A LAB ENVIRONMENT. USE AT YOUR OWN RISK.  IF   *\r\n  * YOU DO NOT UNDERSTAND WHAT THIS SCRIPT DOES OR HOW IT WORKS, *\r\n  * DO NOT USE IT OUTSIDE OF A SECURE, TEST SETTING.             *\r\n  ****************************************************************\r\n\r\n.Link\r\nhttp:\/\/jdhitsolutions.com\/blog\/2014\/08\/friday-fun-text-to-html\r\n\r\n.Link\r\nConvertTo-HTML\r\n#&gt;\r\n[cmdletbinding()]\r\nParam(\r\n[Parameter(Position=0,Mandatory,HelpMessage=\"Enter the path to the file\",\r\nValueFromPipeline,ValueFromPipelineByPropertyName)]\r\n[alias(\"PSPath\")]\r\n[ValidateScript({Test-Path $_})]\r\n[string]$Path,\r\n[switch]$SkipBlankLines,\r\n[switch]$NoLineNumber\r\n)\r\n\r\nBegin {\r\n    Write-Verbose -Message \"Starting $($MyInvocation.Mycommand)\"  \r\n\r\n    $head = @'\r\n&lt;Title&gt;Script Listing&lt;\/Title&gt;\r\n&lt;style&gt;\r\nbody { background-color:#FFFFFF;\r\n       font-family:Consolas;\r\n       font-size:12pt; }\r\ntd, th { border:0px solid black; \r\n         border-collapse:collapse; }\r\nth { color:white;\r\n     background-color:black; }\r\ntable, tr, td, th { padding: 0px; margin: 0px }\r\ntr:nth-child(odd) {background-color: lightgray}\r\ntable { margin-left:25px; }\r\nh2 {\r\n font-family:Tahoma;\r\n}\r\n.footer \r\n{ color:green; \r\n  margin-left:25px; \r\n  font-family:Tahoma\r\n}\r\n\r\n&lt;\/style&gt;\r\n'@\r\n\r\n} #begin\r\n\r\nProcess {\r\n    $file = Resolve-Path -Path $Path\r\n    Write-Verbose \"Processing $($file.providerpath)\"\r\n    $body = \"&lt;H2&gt;$($file.providerpath)&lt;\/H2&gt;\"\r\n    $content = Get-Content -Path $file\r\n\r\n    if ($SkipBlankLines) {\r\n        #filter out blank lines\r\n        Write-Verbose \"Skipping blanks\"\r\n        $content = $content | where {$_ -AND $_ -match \"\\w\"}\r\n    }\r\n\r\n    Write-Verbose \"Converting text to objects\"\r\n    $processed = $content | foreach -begin {$i=0} -process { \r\n    #create a custom object out of each line of text\r\n    $i++\r\n    [pscustomobject]@{Line=$i;\" \"=$_}\r\n    } \r\n\r\n    if ($NoLineNumber) {\r\n      $processed = $processed | Select \" \"\r\n    }\r\n\r\n    Write-Verbose \"Creating HTML\"\r\n    $body+= $processed | ConvertTo-Html -Fragment | foreach {\r\n    #convert spaces to HTML spaces\r\n    $_.replace(\" \",\"&amp;nbsp;\")\r\n    }\r\n\r\n    $post = \"&lt;br&gt;&lt;div class='footer'&gt;$(Get-Date)&lt;\/div&gt;\"\r\n    #create the HTML output and write to the pipeline\r\n    ConvertTo-HTML -Head $head -Body $body -PostContent $post \r\n} #process\r\n\r\nEnd {    \r\n    Write-Verbose -Message \"Ending $($MyInvocation.Mycommand)\"\r\n} #end\r\n\r\n} #end function<\/pre>\n<p>This function takes a file name and turns the text contents into an HTML document.<\/p>\n<p><a href=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/08\/convertto-htmllisting.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/08\/convertto-htmllisting-1024x487.png\" alt=\"convertto-htmllisting\" width=\"474\" height=\"225\" class=\"aligncenter size-large wp-image-3969\" srcset=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/08\/convertto-htmllisting-1024x487.png 1024w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/08\/convertto-htmllisting-300x142.png 300w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/08\/convertto-htmllisting.png 1427w\" sizes=\"auto, (max-width: 474px) 100vw, 474px\" \/><\/a><\/p>\n<p>The function includes an embedded style sheet which is what allows me to use different fonts for the different sections as well as the alternating rows. The only other \"trick\" is that I'm replacing spaces in the original text with the HTML equivalent.<\/p>\n<pre class=\"lang:ps decode:true \" > $body+= $processed | ConvertTo-Html -Fragment | foreach {\r\n    #convert spaces to HTML spaces\r\n    $_.replace(\" \",\"&amp;nbsp;\")\r\n    }<\/pre>\n<p>This is why it is helpful for PowerShell cmdlets to only do one thing. If ConvertTo-HTML automatically wrote to a file I'd have to jump through more hoops. But it doesn't. This function as well only writes the HTML to the pipeline. You will still need to pipe it to Out-File to save. There are some examples in the comment-based help.<\/p>\n<p>You'll notice in the output that the table has a header for the line number and nothing for the line of text. That's why I used a space for the property name in my pscustomobject.<\/p>\n<p>The only other features I have are the options to skip blank lines and line numbers.<\/p>\n<p>Now before you start saying, \"Yeah but what about...\", I know there are other techniques and ISE add-ons to turn scripts into complete and colorized HTML files. You can also simply open the file in a browser as well and have it displayed as text. My function is really aimed as a teaching tool, although it could be kind of cool to have an HTML based library of your PowerShell scripts.<\/p>\n<p>So was this fun? Did you learn something new? If not, there's always next week. Enjoy your weekend.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I love being able to create HTML documents from PowerShell commands. The Convertto-HTML cmdlet will happily turn any object into an HTML table using whatever properties you specify. Plus you can do all sorts of fancy things such as embedding a style sheet in the header, creating HTML fragments and inserting additional HTML elements. Today&#8217;s&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"Friday Fun Text to HTML http:\/\/wp.me\/p1nF6U-11Y #PowerShell","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[271,4],"tags":[229,568,534,540],"class_list":["post-3966","post","type-post","status-publish","format-standard","hentry","category-friday-fun","category-powershell","tag-convertto-html","tag-friday-fun","tag-powershell","tag-scripting"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Friday Fun Text to HTML &#8226; The Lonely Administrator<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/jdhitsolutions.com\/blog\/powershell\/3966\/friday-fun-text-to-html\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Friday Fun Text to HTML &#8226; The Lonely Administrator\" \/>\n<meta property=\"og:description\" content=\"I love being able to create HTML documents from PowerShell commands. The Convertto-HTML cmdlet will happily turn any object into an HTML table using whatever properties you specify. Plus you can do all sorts of fancy things such as embedding a style sheet in the header, creating HTML fragments and inserting additional HTML elements. Today&#039;s...\" \/>\n<meta property=\"og:url\" content=\"https:\/\/jdhitsolutions.com\/blog\/powershell\/3966\/friday-fun-text-to-html\/\" \/>\n<meta property=\"og:site_name\" content=\"The Lonely Administrator\" \/>\n<meta property=\"article:published_time\" content=\"2014-08-22T15:55:21+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2014-08-29T18:15:30+00:00\" \/>\n<meta property=\"og:image\" content=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/08\/html-150x150.jpg\" \/>\n<meta name=\"author\" content=\"Jeffery Hicks\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@JeffHicks\" \/>\n<meta name=\"twitter:site\" content=\"@JeffHicks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Jeffery Hicks\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/3966\\\/friday-fun-text-to-html\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/3966\\\/friday-fun-text-to-html\\\/\"},\"author\":{\"name\":\"Jeffery Hicks\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"headline\":\"Friday Fun Text to HTML\",\"datePublished\":\"2014-08-22T15:55:21+00:00\",\"dateModified\":\"2014-08-29T18:15:30+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/3966\\\/friday-fun-text-to-html\\\/\"},\"wordCount\":572,\"commentCount\":4,\"publisher\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"image\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/3966\\\/friday-fun-text-to-html\\\/#primaryimage\"},\"thumbnailUrl\":\"http:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2014\\\/08\\\/html-150x150.jpg\",\"keywords\":[\"ConvertTo-HTML\",\"Friday Fun\",\"PowerShell\",\"Scripting\"],\"articleSection\":[\"Friday Fun\",\"PowerShell\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/3966\\\/friday-fun-text-to-html\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/3966\\\/friday-fun-text-to-html\\\/\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/3966\\\/friday-fun-text-to-html\\\/\",\"name\":\"Friday Fun Text to HTML &#8226; The Lonely Administrator\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/3966\\\/friday-fun-text-to-html\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/3966\\\/friday-fun-text-to-html\\\/#primaryimage\"},\"thumbnailUrl\":\"http:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2014\\\/08\\\/html-150x150.jpg\",\"datePublished\":\"2014-08-22T15:55:21+00:00\",\"dateModified\":\"2014-08-29T18:15:30+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/3966\\\/friday-fun-text-to-html\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/3966\\\/friday-fun-text-to-html\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/3966\\\/friday-fun-text-to-html\\\/#primaryimage\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2014\\\/08\\\/html.jpg\",\"contentUrl\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2014\\\/08\\\/html.jpg\",\"width\":600,\"height\":428},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/3966\\\/friday-fun-text-to-html\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Friday Fun\",\"item\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/category\\\/friday-fun\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Friday Fun Text to HTML\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/\",\"name\":\"The Lonely Administrator\",\"description\":\"Practical Advice for the Automating IT Pro\",\"publisher\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\",\"name\":\"Jeffery Hicks\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg\",\"caption\":\"Jeffery Hicks\"},\"logo\":{\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Friday Fun Text to HTML &#8226; The Lonely Administrator","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3966\/friday-fun-text-to-html\/","og_locale":"en_US","og_type":"article","og_title":"Friday Fun Text to HTML &#8226; The Lonely Administrator","og_description":"I love being able to create HTML documents from PowerShell commands. The Convertto-HTML cmdlet will happily turn any object into an HTML table using whatever properties you specify. Plus you can do all sorts of fancy things such as embedding a style sheet in the header, creating HTML fragments and inserting additional HTML elements. Today's...","og_url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3966\/friday-fun-text-to-html\/","og_site_name":"The Lonely Administrator","article_published_time":"2014-08-22T15:55:21+00:00","article_modified_time":"2014-08-29T18:15:30+00:00","og_image":[{"url":"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/08\/html-150x150.jpg","type":"","width":"","height":""}],"author":"Jeffery Hicks","twitter_card":"summary_large_image","twitter_creator":"@JeffHicks","twitter_site":"@JeffHicks","twitter_misc":{"Written by":"Jeffery Hicks","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3966\/friday-fun-text-to-html\/#article","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3966\/friday-fun-text-to-html\/"},"author":{"name":"Jeffery Hicks","@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"headline":"Friday Fun Text to HTML","datePublished":"2014-08-22T15:55:21+00:00","dateModified":"2014-08-29T18:15:30+00:00","mainEntityOfPage":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3966\/friday-fun-text-to-html\/"},"wordCount":572,"commentCount":4,"publisher":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"image":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3966\/friday-fun-text-to-html\/#primaryimage"},"thumbnailUrl":"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/08\/html-150x150.jpg","keywords":["ConvertTo-HTML","Friday Fun","PowerShell","Scripting"],"articleSection":["Friday Fun","PowerShell"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/jdhitsolutions.com\/blog\/powershell\/3966\/friday-fun-text-to-html\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3966\/friday-fun-text-to-html\/","url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3966\/friday-fun-text-to-html\/","name":"Friday Fun Text to HTML &#8226; The Lonely Administrator","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3966\/friday-fun-text-to-html\/#primaryimage"},"image":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3966\/friday-fun-text-to-html\/#primaryimage"},"thumbnailUrl":"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/08\/html-150x150.jpg","datePublished":"2014-08-22T15:55:21+00:00","dateModified":"2014-08-29T18:15:30+00:00","breadcrumb":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3966\/friday-fun-text-to-html\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/jdhitsolutions.com\/blog\/powershell\/3966\/friday-fun-text-to-html\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3966\/friday-fun-text-to-html\/#primaryimage","url":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/08\/html.jpg","contentUrl":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/08\/html.jpg","width":600,"height":428},{"@type":"BreadcrumbList","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3966\/friday-fun-text-to-html\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Friday Fun","item":"https:\/\/jdhitsolutions.com\/blog\/category\/friday-fun\/"},{"@type":"ListItem","position":2,"name":"Friday Fun Text to HTML"}]},{"@type":"WebSite","@id":"https:\/\/jdhitsolutions.com\/blog\/#website","url":"https:\/\/jdhitsolutions.com\/blog\/","name":"The Lonely Administrator","description":"Practical Advice for the Automating IT Pro","publisher":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/jdhitsolutions.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9","name":"Jeffery Hicks","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg","url":"https:\/\/secure.gravatar.com\/avatar\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg","caption":"Jeffery Hicks"},"logo":{"@id":"https:\/\/secure.gravatar.com\/avatar\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg"}}]}},"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_likes_enabled":true,"jetpack-related-posts":[{"id":1384,"url":"https:\/\/jdhitsolutions.com\/blog\/scripting\/1384\/create-a-master-powershell-online-help-page\/","url_meta":{"origin":3966,"position":0},"title":"Create a Master PowerShell Online Help Page","author":"Jeffery Hicks","date":"April 28, 2011","format":false,"excerpt":"As I hope you know, PowerShell cmdlets can include links to online help. This is very handy because it is much easier to keep online help up to date. To see online help for a cmdlet use the -online parameter. get-help get-wmiobject -online I decided to take things to another\u2026","rel":"","context":"In &quot;Miscellaneous&quot;","block_context":{"text":"Miscellaneous","link":"https:\/\/jdhitsolutions.com\/blog\/category\/miscellaneous\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":4985,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4985\/converting-text-to-html-revised\/","url_meta":{"origin":3966,"position":1},"title":"Converting Text to HTML Revised","author":"Jeffery Hicks","date":"May 9, 2016","format":false,"excerpt":"A few years ago I published a PowerShell function to convert text files into HTML listings. I thought it would be handy to convert scripts to HTML documents with line numbering and some formatting. Turns out someone actually used it! He had some questions about the function which led me\u2026","rel":"","context":"In &quot;PowerShell&quot;","block_context":{"text":"PowerShell","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},"img":{"alt_text":"convertto-htmllisting2","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2016\/05\/convertto-htmllisting2_thumb.png?resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2016\/05\/convertto-htmllisting2_thumb.png?resize=350%2C200 1x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2016\/05\/convertto-htmllisting2_thumb.png?resize=525%2C300 1.5x"},"classes":[]},{"id":889,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/889\/get-some-style\/","url_meta":{"origin":3966,"position":2},"title":"Get Some Style","author":"Jeffery Hicks","date":"August 31, 2010","format":false,"excerpt":"Windows PowerShell has many ways to present and store information. You can display it to the screen, write it to a file, send it to a printer, create an CSV or XML file or even a pretty HTML report. The ConvertTo-HTML cmdlet underwent a significant facelift for v2.0 and is\u2026","rel":"","context":"In &quot;PowerShell&quot;","block_context":{"text":"PowerShell","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":3516,"url":"https:\/\/jdhitsolutions.com\/blog\/scripting\/3516\/friday-fun-50-shades-of-powershell-html-reports\/","url_meta":{"origin":3966,"position":3},"title":"Friday Fun: 50 Shades of PowerShell HTML Reports","author":"Jeffery Hicks","date":"October 25, 2013","format":false,"excerpt":"I've been working on a project for a client that includes creating an HTML report, generated by PowerShell. I originally thought I would include a certain feature but decided against it. However, this is so cool I thought I'd share it with you as a Friday Fun article. I've done\u2026","rel":"","context":"In &quot;Friday Fun&quot;","block_context":{"text":"Friday Fun","link":"https:\/\/jdhitsolutions.com\/blog\/category\/friday-fun\/"},"img":{"alt_text":"happyreport","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2012\/11\/happyreport-150x150.png?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":2152,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/2152\/create-an-html-powershell-help-page\/","url_meta":{"origin":3966,"position":4},"title":"Create an HTML PowerShell Help Page","author":"Jeffery Hicks","date":"April 3, 2012","format":false,"excerpt":"Yesterday I posted an article about getting the online url for a cmdlet help topic. Today I want to demonstrate how we might take advantage of this piece of information. Since the link is already in the form of a URL, wouldn't it make sense to put this in an\u2026","rel":"","context":"In &quot;PowerShell&quot;","block_context":{"text":"PowerShell","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2012\/04\/cmdlethelp-1-300x177.png?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":2119,"url":"https:\/\/jdhitsolutions.com\/blog\/scripting\/2119\/create-html-bar-charts-from-powershell\/","url_meta":{"origin":3966,"position":5},"title":"Create HTML Bar Charts from PowerShell","author":"Jeffery Hicks","date":"February 16, 2012","format":false,"excerpt":"I saw a very nice mention on Twitter today where someone had taken an idea of mine and created something practical and in production. It is always nice to hear. The inspiring article was something I worked up that showed using the PowerShell console as a graphing tool. Of course\u2026","rel":"","context":"In &quot;PowerShell v2.0&quot;","block_context":{"text":"PowerShell v2.0","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell-v2-0\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2012\/02\/html-drives-300x214.png?resize=350%2C200","width":350,"height":200},"classes":[]}],"_links":{"self":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/3966","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/comments?post=3966"}],"version-history":[{"count":0,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/3966\/revisions"}],"wp:attachment":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/media?parent=3966"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/categories?post=3966"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/tags?post=3966"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}