Reputation: 23
hi i wrote a simple script for outputting the quickfixengineering in html but something is not realy working as pleased.
$qfe = gwmi -class win32_quickfixengineering
$qfe | select-object -property HotFixID, Description, Caption,
@{LABEL="URL"; EXPRESSION={ "<a href=""" + $_.caption + """>" + $_.caption + "</a>" } } |
ConvertTo-html -Head $style -body "<H2>Windows Update Information (quickfixengineering)
</H2><H3>Creation Date: $date / Entries found: $fixcount</H3> " |
Out-File $scriptpath\html\$file
my idea is to put the caption property in html link tags before converting it to html, but when it is actualy converted certain characters are converted to html character codes.
like so:
<a href="http://go.microsoft.com/fwlink/?LinkId=133041">http:
//go.microsoft.com/fwlink/?LinkId=133041</a>
i tried several things. the '' characters arent realy helping me too (dont know how to call these in english.) if things arent literal enough alrdy these make it even more literal.
does anyone have an idea / can help me please sorting this out :) tnx
Upvotes: 1
Views: 2894
Reputation: 60938
Try this:
$qfe = gwmi -class win32_quickfixengineering
$qfe | select-object -property HotFixID, Description, Caption,
@{LABEL="URL"; EXPRESSION={ "<a href=""" + $_.caption + """>" + $_.caption + "</a>" } } |
ConvertTo-html -Head $style -body "<H2>Windows Update Information (quickfixengineering)
</H2><H3>Creation Date: $date / Entries found: $fixcount</H3> " |
% { ($_.Replace("<","<")).Replace(">",">").replace(""",'"') }|
Out-File $scriptpath\html\$file
Upvotes: 0
Reputation: 54911
Try to decode it before saving:
$qfe = gwmi -class win32_quickfixengineering
$html = $qfe | select-object -property HotFixID, Description, Caption,
@{LABEL="URL"; EXPRESSION={ "<a href=""" + $_.caption + """>" + $_.caption + "</a>" } } |
ConvertTo-html -Head $style -body "<H2>Windows Update Information (quickfixengineering)
</H2><H3>Creation Date: $date / Entries found: $fixcount</H3> "
#Decode lines with link and save
$html = $html | % { if($_ -match 'a href' ) { [System.Web.HttpUtility]::HtmlDecode($_) } else { $_ } }
$html | Out-File $scriptpath\html\$file
Upvotes: 4