0

嗨,我编写了一个简单的脚本,用于在 html 中输出 quickfixengineering,但有些东西并没有真正令人满意。

$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

我的想法是在将其转换为 html 之前将标题属性放在 html 链接标签中,但是当它实际转换时,某些字符会转换为 html 字符代码。

像这样:

&lt;a href=&quot;http://go.microsoft.com/fwlink/?LinkId=133041&quot;&gt;http:
//go.microsoft.com/fwlink/?LinkId=133041&lt;/a&gt;

我尝试了几件事。'' 字符也没有真正帮助我(不知道如何用英语称呼这些。)如果事情不够字面化,这些会使它更加字面化。

有没有人有想法/可以帮我解决这个问题:) tnx

4

2 回答 2

3

在保存之前尝试对其进行解码:

$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
于 2013-02-13T13:57:53.737 回答
0

试试这个:

$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("&lt;","<")).Replace("&gt;",">").replace("&quot;",'"') }|
Out-File $scriptpath\html\$file
于 2013-02-13T14:03:51.557 回答