{"id":7163,"date":"2020-01-13T13:23:46","date_gmt":"2020-01-13T18:23:46","guid":{"rendered":"https:\/\/jdhitsolutions.com\/blog\/?p=7163"},"modified":"2020-01-13T13:23:55","modified_gmt":"2020-01-13T18:23:55","slug":"creating-linked-html-with-powershell","status":"publish","type":"post","link":"https:\/\/jdhitsolutions.com\/blog\/powershell\/7163\/creating-linked-html-with-powershell\/","title":{"rendered":"Creating Linked HTML with PowerShell"},"content":{"rendered":"<p>Today's post is about a niche problem or something that maybe you never considered before. And while I will share a finished PowerShell function, you may want to create your own tooling based on the techniques and concepts. The problem begins with a command like this:<\/p>\n<pre class=\"lang:ps mark:0 decode:true\">Get-HotFix -ComputerName $env:computername |\nSort-Object Description,InstalledOn -Descending |\nSelect-Object Description,HotfixID,Caption,InstalledBy,InstalledOn\n<\/pre>\n<p>And suppose you want to create an HTML report with this information which you can do by piping this to <a title=\"Read online help for this command\" href=\"http:\/\/go.microsoft.com\/fwlink\/?LinkID=113290\" target=\"_blank\" rel=\"noopener noreferrer\">ConvertTo-HTML<\/a> and then <a title=\"Read online help for this command\" href=\"http:\/\/go.microsoft.com\/fwlink\/?LinkID=113363\" target=\"_blank\" rel=\"noopener noreferrer\">Out-File<\/a>. The result is adequate.<\/p>\n<p><a href=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/01\/r.png\"><img loading=\"lazy\" decoding=\"async\" style=\"display: inline; background-image: none;\" title=\"Converted HTML Output\" src=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/01\/r_thumb.png\" alt=\"Converted HTML output\" width=\"1028\" height=\"469\" border=\"0\" \/><\/a><\/p>\n<p>Yes, I know I can make it pretty by applying a style but that won't help one drawback. The links under the Caption column aren't actual hyperlinks. Wouldn't it be nice if they were? In fact, you may have data from any number of other sources that include a link that you want to turn into an html page. Here's one approach you might take.<\/p>\n<p>First, I'm going to save my hotfix data as an HTML fragment.<\/p>\n<pre class=\"lang:ps mark:0 decode:true\">$h = Get-HotFix -ComputerName $env:computername |\nSort-Object Description,InstalledOn -Descending |\nSelect-Object Description,HotfixID,Caption,InstalledBy,InstalledOn |\nConvertTo-Html -Fragment\n<\/pre>\n<p>What I need to do is change the table definitions for the caption to include an &lt;a href=&gt; tag. What I need to do is change text like this:<\/p>\n<pre class=\"lang:ps mark:0 decode:true\">&lt;td&gt;http:\/\/support.microsoft.com\/?kbid=4509096&lt;\/td&gt;\n<\/pre>\n<p>Into this:<\/p>\n<pre class=\"lang:ps mark:0 decode:true\">&lt;td&gt;&lt;a href=\"http:\/\/support.microsoft.com\/?kbid=4509096\"&gt;http:\/\/support.microsoft.com\/?kbid=4509096&gt;&lt;\/a&gt;&lt;\/td&gt;\n<\/pre>\n<p>This sounds like a good use case for regular expressions. Here's a pattern to match on a url.<\/p>\n<pre class=\"lang:ps mark:0 decode:true\">[regex]$rx = \"http(s)?:\\\/\\\/[a-zA-Z0-9\\.\\\/\\?\\%=&amp;\\$-]+\"\n<\/pre>\n<p>Yes, I know there are many ways to define a regular expression pattern, but this will suffice for my examples.<\/p>\n<p>My approach is to go through each line of the HTML and there is a matching URL replace it with the necessary additional tags. To keep it simple, I'll create a new here string which will eventually be the body of the HTML document.<\/p>\n<pre class=\"lang:ps mark:0 decode:true\">[string]$out = @\"\n&lt;H1&gt;$env:computername&lt;\/H1&gt;\n\"@\n<\/pre>\n<p>Next, I'll go through each line of the HTML stored in $h. If the line matches on the regex object I will get the matching value and save it to a variable. With that I can build the replacement text with the link. The last step is to replace the line with the link. This has the effect of replacing just the http string with the new link.<\/p>\n<pre class=\"lang:ps mark:0 decode:true\">foreach ($line in $h) {\n    if ($rx.IsMatch($line)) {\n        $value = $rx.Match($line).value\n        $link = \"&lt;a href = \"\"$value\"\" target = \"\"_blank\"\"&gt;$value&lt;\/a&gt;\"\n        $out += $rx.Replace($line, $link)\n    }\n    else {\n        #just add the line\n        $out += $line\n    }\n}\n<\/pre>\n<p>Each new line is added to the here string. If the line doesn't match the regular expression, I just add it as is to the here string, $out.<\/p>\n<p><a href=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/01\/b.png\"><img loading=\"lazy\" decoding=\"async\" style=\"display: inline; background-image: none;\" title=\"b\" src=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/01\/b_thumb.png\" alt=\"b\" width=\"1028\" height=\"131\" border=\"0\" \/><\/a><\/p>\n<p>You can see that the &lt;td&gt; element with the URL now has a hyperlink. Al that remains is to turn it into an HTML document.<\/p>\n<pre class=\"lang:ps mark:0 decode:true\">$head = @\"\n&lt;title&gt;Hot Fix Report&lt;\/title&gt;\n&lt;style&gt;\ntable\n{\nfont-family:\"Trebuchet MS\", Arial, Helvetica, sans-serif;\nborder-collapse:collapse;\n}\ntd\n{\nfont-size:1em;\nborder:1px solid #98bf21;\npadding:5px 5px 5px 5px;\n}\nth\n{\nfont-size:1.1em;\ntext-align:center;\npadding-top:5px;\npadding-bottom:5px;\npadding-right:7px;\npadding-left:7px;\nbackground-color:#A7C942;\ncolor:#ffffff;\n}\nname tr\n{\ncolor: #060606;\nbackground-color:#EAF2D3;\n}\n&lt;\/style&gt;\n\"@\n\nConvertto-Html -head $head -body $out -PostContent \"&lt;h5&gt;&lt;i&gt;report run $(Get-Date) &lt;\/i&gt;&lt;\/h5&gt;\" | out-file D:\\temp\\hotfix.html\n<\/pre>\n<p>I'm embedding a style sheet into the document.<\/p>\n<p><a href=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/01\/c.png\"><img loading=\"lazy\" decoding=\"async\" style=\"display: inline; background-image: none;\" title=\"A hyperlinked enabled HTML report\" src=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/01\/c_thumb.png\" alt=\"A hyperlinked enabled HTML report\" width=\"1028\" height=\"581\" border=\"0\" \/><\/a><\/p>\n<p>Of course, what would make this even easier is a function.<\/p>\n<pre class=\"lang:ps mark:0 decode:true\">Function ConvertTo-HTML2 {\n    [cmdletbinding()]\n    [outputtype([system.string])]\n    Param(\n        [Parameter(Mandatory, ValueFromPipeline)]\n        [object]$InputObject,\n        [switch]$Fragment,\n        [ValidateSet(\"Table\", \"List\")]\n        [string]$As,\n        [string[]]$Head,\n        [string]$Title,\n        [uri]$CSSUri,\n        [string[]]$PostContent,\n        [string[]]$PreContent,\n        [object[]]$Property\n    )\n    Begin {\n        Write-Verbose \"[$((Get-Date).TimeofDay) BEGIN  ] Starting $($myinvocation.mycommand)\"\n        [regex]$rx = \"http(s)?:\\\/\\\/[a-zA-Z0-9\\.\\\/\\?\\%=&amp;\\$-]+\"\n        $in = @()\n        $processing = $False\n    } #begin\n\n    Process {\n        if (-Not $processing) {\n            #only display this message once\n            Write-Verbose \"[$((Get-Date).TimeofDay) PROCESS] Storing Data \"\n        }\n        $in += $InputObject\n        $processing = $True\n    } #process\n\n    End {\n        Write-Verbose \"[$((Get-Date).TimeofDay) END    ] Converting input to html fragment\"\n        [void]$PSBoundParameters.remove(\"InputObject\")\n        $h = $in | ConvertTo-Html @PSBoundParameters\n        [string]$out = @\"\n\"@\n\n        foreach ($line in $h) {\n            if ($rx.IsMatch($line) -AND ($line -notmatch \"DOCTYPE html PUBLIC\") -AND ($line -notmatch \"html xmlns\")) {\n                $value = $rx.Match($line).value\n                $link = \"&lt;a href = \"\"$value\"\" target = \"\"_blank\"\"&gt;$value&lt;\/a&gt;\"\n                $out += $rx.Replace($line, $link)\n            }\n            else {\n                #just add the line\n                $out += $line\n            }\n        }\n        $out\n        Write-Verbose \"[$((Get-Date).TimeofDay) END    ] Ending $($myinvocation.mycommand)\"\n    } #end\n\n} #close ConvertTo-HTML2\n<\/pre>\n<p>This function is essentially a wrapper for ConvertTo-HTML. The parameters are the same so that I can simply splat PSBoundParameters to ConvertTo-HTML. The function gets all of the input and then in the End block goes through the regex replacing. The function ends by writing HTML to the pipeline like ConvertTo-HTML. But now I can run a command like:<\/p>\n<pre class=\"lang:ps mark:0 decode:true\">Get-HotFix -ComputerName $env:computername |\nSort-Object Description, InstalledOn -Descending |\nConvertTo-HTML2 -head $head -property  Description, HotfixID, Caption, InstalledBy, InstalledOn -PreContent \"&lt;H1&gt;$env:computername&lt;\/H1&gt;\" -PostContent \"&lt;h5&gt;&lt;i&gt;report run $(Get-Date) &lt;\/i&gt;&lt;\/h5&gt;\" | Out-File D:\\temp\\t.html\n<\/pre>\n<p>to create the same report. This example is using the $head variable from before. I can use this function with anything that has an http type link.<\/p>\n<p>Here's a function I have to get an RSS feed.<\/p>\n<pre class=\"lang:ps mark:0 decode:true\">Function Get-RSSFeed {\n\n    Param (\n        [Parameter(Position = 0, ValueFromPipeline, ValueFromPipelineByPropertyName)]\n        [ValidateNotNullOrEmpty()]\n        [ValidatePattern(\"^http(s)?:\\\/\\\/\")]\n        [Alias('url')]\n        [string[]]$Path = \"http:\/\/jdhitsolutions.com\/blog\/feed\"\n    )\n\n    Begin {\n        Write-Verbose -Message \"Starting $($MyInvocation.Mycommand)\"\n    } #begin\n\n    Process {\n        foreach ($item in $path) {\n            $data = Invoke-RestMethod -Uri $item\n            foreach ($entry in $data) {\n                #link might be different names\n                if ($entry.origLink) {\n                    $link = $entry.origLink\n                }\n                elseif ($entry.link) {\n                    $link = $entry.link\n                }\n                else {\n                    $link = \"unknown\"\n                }\n                #clean up description\n                #hash table of HTML codes\n                #http:\/\/www.ascii.cl\/htmlcodes.htm\n                $decode = @{\n                    '&lt;(.|\\n)+?&gt;' = \"\"\n                    '\u2019'    = \"'\"\n                    '\u201c'    = '\"'\n                    '\u201d'    = '\"'\n                    '\u00bb'     = \"...\"\n                    '\u2013'    = \"--\"\n                    '\u2026'    = \"...\"\n                    '\u00e2\u20ac\u201c'        = \"@\"\n                    ' '     = \" \"\n                }\n\n                #description could be an XML element or a simple string\n                if ($entry.description -is [System.Xml.XmlElement]) {\n                    $description = $entry.description.innertext\n                }\n                else {\n                    $description = $entry.description\n                }\n\n                foreach ($key in $decode.keys) {\n                    [regex]$rgx = $key\n                    $description = $rgx.Replace($description, $decode.Item($key)).Trim()\n                }\n\n                #create a custom object\n                [pscustomobject]@{\n                    Title       = $entry.title\n                    Author      = $entry.creator.innertext\n                    Description = $description\n                    Published   = $entry.pubDate -as [datetime]\n                    Category    = $entry.category.'#cdata-section'\n                    Link        = $Link\n                } #hash\n\n            } #foreach entry\n        } #foreach item\n\n    } #process\n\n    End {\n        Write-Verbose -Message \"Ending $($MyInvocation.Mycommand)\"\n    } #end\n\n} #end Get-RSSFeed\n<\/pre>\n<p>I can use it to create an HTML report with links.<\/p>\n<pre class=\"lang:ps mark:0 decode:true\">$cparams = @{\n    Title = \"The Lonely Administrator\" \n    CSSUri = \"C:\\scripts\\samplecss\\sample2.css\"\n    Property = \"Title\",\"Description\",\"Published\",\"Link\"\n    As = \"table\"\n}\n\nGet-RSSFeed  | ConvertTo-HTML2 @cparams | Out-File d:\\temp\\rss.html\n<\/pre>\n<p><a href=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/01\/d.png\"><img loading=\"lazy\" decoding=\"async\" style=\"display: inline; background-image: none;\" title=\"A PowerShell generated RSS report\" src=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/01\/d_thumb.png\" alt=\"A PowerShell generated RSS report\" width=\"1028\" height=\"537\" border=\"0\" \/><\/a><\/p>\n<p>I hope you'll give the code snippets a try for yourself. And if you feel regular expressions are too hard for you, stay tuned. I am wrapping up a <a href=\"http:\/\/www.pluralsight.com\" target=\"_blank\" rel=\"noopener noreferrer\">Pluralsight<\/a> course on PowerShell and Regular Expressions that hopefully will help take away the mystery.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Today&#8217;s post is about a niche problem or something that maybe you never considered before. And while I will share a finished PowerShell function, you may want to create your own tooling based on the techniques and concepts. The problem begins with a command like this: Get-HotFix -ComputerName $env:computername | Sort-Object Description,InstalledOn -Descending | Select-Object&#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":"New on the blog: Creating Linked HTML with #PowerShell and Regular Expressions","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":[4,8],"tags":[229,534,540],"class_list":["post-7163","post","type-post","status-publish","format-standard","hentry","category-powershell","category-scripting","tag-convertto-html","tag-powershell","tag-scripting"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.6 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Creating Linked HTML with PowerShell &#8226; The Lonely Administrator<\/title>\n<meta name=\"description\" content=\"Here&#039;s how I create HTML reports that contain links into pages wth live and clickable links. This is possible through PowerShell and regular expressions.\" \/>\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\/7163\/creating-linked-html-with-powershell\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Creating Linked HTML with PowerShell &#8226; The Lonely Administrator\" \/>\n<meta property=\"og:description\" content=\"Here&#039;s how I create HTML reports that contain links into pages wth live and clickable links. This is possible through PowerShell and regular expressions.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/jdhitsolutions.com\/blog\/powershell\/7163\/creating-linked-html-with-powershell\/\" \/>\n<meta property=\"og:site_name\" content=\"The Lonely Administrator\" \/>\n<meta property=\"article:published_time\" content=\"2020-01-13T18:23:46+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2020-01-13T18:23:55+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/01\/r_thumb.png\" \/>\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=\"6 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/7163\\\/creating-linked-html-with-powershell\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/7163\\\/creating-linked-html-with-powershell\\\/\"},\"author\":{\"name\":\"Jeffery Hicks\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"headline\":\"Creating Linked HTML with PowerShell\",\"datePublished\":\"2020-01-13T18:23:46+00:00\",\"dateModified\":\"2020-01-13T18:23:55+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/7163\\\/creating-linked-html-with-powershell\\\/\"},\"wordCount\":577,\"commentCount\":1,\"publisher\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"image\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/7163\\\/creating-linked-html-with-powershell\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/01\\\/r_thumb.png\",\"keywords\":[\"ConvertTo-HTML\",\"PowerShell\",\"Scripting\"],\"articleSection\":[\"PowerShell\",\"Scripting\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/7163\\\/creating-linked-html-with-powershell\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/7163\\\/creating-linked-html-with-powershell\\\/\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/7163\\\/creating-linked-html-with-powershell\\\/\",\"name\":\"Creating Linked HTML with PowerShell &#8226; The Lonely Administrator\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/7163\\\/creating-linked-html-with-powershell\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/7163\\\/creating-linked-html-with-powershell\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/01\\\/r_thumb.png\",\"datePublished\":\"2020-01-13T18:23:46+00:00\",\"dateModified\":\"2020-01-13T18:23:55+00:00\",\"description\":\"Here's how I create HTML reports that contain links into pages wth live and clickable links. This is possible through PowerShell and regular expressions.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/7163\\\/creating-linked-html-with-powershell\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/7163\\\/creating-linked-html-with-powershell\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/7163\\\/creating-linked-html-with-powershell\\\/#primaryimage\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/01\\\/r_thumb.png\",\"contentUrl\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/01\\\/r_thumb.png\",\"width\":1028,\"height\":469},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/7163\\\/creating-linked-html-with-powershell\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"PowerShell\",\"item\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/category\\\/powershell\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Creating Linked HTML with PowerShell\"}]},{\"@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":"Creating Linked HTML with PowerShell &#8226; The Lonely Administrator","description":"Here's how I create HTML reports that contain links into pages wth live and clickable links. This is possible through PowerShell and regular expressions.","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\/7163\/creating-linked-html-with-powershell\/","og_locale":"en_US","og_type":"article","og_title":"Creating Linked HTML with PowerShell &#8226; The Lonely Administrator","og_description":"Here's how I create HTML reports that contain links into pages wth live and clickable links. This is possible through PowerShell and regular expressions.","og_url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/7163\/creating-linked-html-with-powershell\/","og_site_name":"The Lonely Administrator","article_published_time":"2020-01-13T18:23:46+00:00","article_modified_time":"2020-01-13T18:23:55+00:00","og_image":[{"url":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/01\/r_thumb.png","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":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/7163\/creating-linked-html-with-powershell\/#article","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/7163\/creating-linked-html-with-powershell\/"},"author":{"name":"Jeffery Hicks","@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"headline":"Creating Linked HTML with PowerShell","datePublished":"2020-01-13T18:23:46+00:00","dateModified":"2020-01-13T18:23:55+00:00","mainEntityOfPage":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/7163\/creating-linked-html-with-powershell\/"},"wordCount":577,"commentCount":1,"publisher":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"image":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/7163\/creating-linked-html-with-powershell\/#primaryimage"},"thumbnailUrl":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/01\/r_thumb.png","keywords":["ConvertTo-HTML","PowerShell","Scripting"],"articleSection":["PowerShell","Scripting"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/jdhitsolutions.com\/blog\/powershell\/7163\/creating-linked-html-with-powershell\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/7163\/creating-linked-html-with-powershell\/","url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/7163\/creating-linked-html-with-powershell\/","name":"Creating Linked HTML with PowerShell &#8226; The Lonely Administrator","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/7163\/creating-linked-html-with-powershell\/#primaryimage"},"image":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/7163\/creating-linked-html-with-powershell\/#primaryimage"},"thumbnailUrl":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/01\/r_thumb.png","datePublished":"2020-01-13T18:23:46+00:00","dateModified":"2020-01-13T18:23:55+00:00","description":"Here's how I create HTML reports that contain links into pages wth live and clickable links. This is possible through PowerShell and regular expressions.","breadcrumb":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/7163\/creating-linked-html-with-powershell\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/jdhitsolutions.com\/blog\/powershell\/7163\/creating-linked-html-with-powershell\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/7163\/creating-linked-html-with-powershell\/#primaryimage","url":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/01\/r_thumb.png","contentUrl":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/01\/r_thumb.png","width":1028,"height":469},{"@type":"BreadcrumbList","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/7163\/creating-linked-html-with-powershell\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"PowerShell","item":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},{"@type":"ListItem","position":2,"name":"Creating Linked HTML with PowerShell"}]},{"@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":1977,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/1977\/the-powershell-morning-report\/","url_meta":{"origin":7163,"position":0},"title":"The PowerShell Morning Report","author":"Jeffery Hicks","date":"January 10, 2012","format":false,"excerpt":"I love how easy it is to manage computers with Windows PowerShell. It is a great reporting tool, but often I find people getting locked into one approach. I'm a big believer in flexibility and re-use and using objects in the pipeline wherever I can. So I put together a\u2026","rel":"","context":"In &quot;PowerShell&quot;","block_context":{"text":"PowerShell","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},"img":{"alt_text":"Zazu","src":"https:\/\/i0.wp.com\/www.lionking.org\/imgarchive\/Clip_Art\/zazu03.gif?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":6065,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/6065\/converting-powershell-to-markdown\/","url_meta":{"origin":7163,"position":1},"title":"Converting PowerShell to Markdown","author":"Jeffery Hicks","date":"August 15, 2018","format":false,"excerpt":"I have been working a lot with markdown documents over the last year or so, primarily due to all the books I've been working on published at Leanpub.com. With the growing use of markdown in projects like Platyps for generating help files and documentation, you will most likely be using\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\/2018\/08\/image_thumb-2.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2018\/08\/image_thumb-2.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2018\/08\/image_thumb-2.png?resize=525%2C300&ssl=1 1.5x"},"classes":[]},{"id":889,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/889\/get-some-style\/","url_meta":{"origin":7163,"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":4435,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4435\/sql-database-report-revised\/","url_meta":{"origin":7163,"position":3},"title":"SQL Database Report Revised","author":"Jeffery Hicks","date":"July 3, 2015","format":false,"excerpt":"Last year I wrote an article that explained how to use the SQLSERVER PSDrive to create an HTML report highlighting some server and database information. If you want a refresher you can find that article here. In short, you can install the SQL Server PowerShell module on your client desktop\u2026","rel":"","context":"In &quot;PowerShell&quot;","block_context":{"text":"PowerShell","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},"img":{"alt_text":"sqldatabases","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2015\/07\/sqldatabases-300x160.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":7163,"position":4},"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":[]},{"id":7872,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/7872\/better-performance-counters-with-powershell\/","url_meta":{"origin":7163,"position":5},"title":"Better Performance Counters with PowerShell","author":"Jeffery Hicks","date":"November 12, 2020","format":false,"excerpt":"I wanted to tell you about another addition to the latest release of the PSScriptTools module. This is something I've written about before but I decided to add the function to the module. I hope you find it a much easier way to work with performance counters. And it works\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\/2020\/11\/counters-form.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/11\/counters-form.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/11\/counters-form.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/11\/counters-form.png?resize=700%2C400&ssl=1 2x"},"classes":[]}],"_links":{"self":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/7163","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=7163"}],"version-history":[{"count":0,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/7163\/revisions"}],"wp:attachment":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/media?parent=7163"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/categories?post=7163"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/tags?post=7163"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}