How to render clickable link using Powershell
powershell, powershell-2.0, powershell-ise
Solution
PowerShell encodes special characters. One way to solve this would be to convert them back and then write the result ot a file:
$pso = New-Object PSObject -Property @{
SiteUrl = $spweb.url
PageTitle= $PageTitle
PageUrl = "<a href='$PagesUrl'>$PageTitle</a>"
} | ConvertTo-Html
$pso -replace '>','>' -replace '<','<' -replace ''',"'" |
Out-File \\myfolder\InventoryReports\$CurrentMonth.html
UPDATE:
Here's a better way that will take care of all html entities:
Add-Type -AssemblyName System.Web
[System.Web.HttpUtility]::HtmlDecode($pso)
Problem
I am using below powershell script to write the output to a html file, the issue is its rendering everything as text. My code: ``` $PagesObject = New-Object PSObject Add-Member -input $PagesObject noteproperty 'Site Url' $spweb.url Add-Member -input $PagesObject noteproperty 'Page Title' $PageTitle Add-Member -input $PagesObject noteproperty 'Page Url' "<a href="$PagesUrl">$PageTitle</a>" $results += $PagesObject $results | ConvertTo-HTML -head $a -body | Out-File \\myfolder\InventoryReports\$CurrentMonth.html ``` I want to render it as clickable link check below screenshot to see how it is rendering now Thanks in advance