2013-02-13 64 views
0

您好,我寫了一個簡單的腳本來輸出HTML中的quickfixengineering,但事實並非如此令人滿意。convertto-html輸出字符代碼而不是字符

$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鏈接標籤Caption屬性將其轉換爲HTML, 但是當它被actualy轉換某些字符轉換爲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

回答

1

嘗試保存之前對其進行解碼:

$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 
+0

AAHķdidnt知道有一個函數將其整齊地編碼爲html。很好的答案tnx很多 – Moose 2013-02-13 21:26:28

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 
+0

工作同樣偉大,快速幫助tnx:D – Moose 2013-02-13 21:26:53

相關問題