| HungYu 的个人资料PowerShell@HungYuWu照片日志列表 | 帮助 |
|
2007/1/6 PowerShell:ConvertTo-Html在PowerShell中
若我們想要只選擇Name以及Status欄位,加上Title "Get-Service"以及標題"<H2>The result of get-service</H2>" 且若狀態為Running則該列背景為綠色,狀態為Stopped則為紅色 則可以使用以下指令 PS C:\> get-service | ConvertTo-Html -Title "Get-Service" -Body "<H2>The result of get-service</H2> " -Property Name,Status | foreach {if($_ -like "*<td>Running</td>*"){$_ -replace "<tr>", "<tr bgcolor=green>"}elseif($_ -like "*<td>Stopped</td>*"){$_ -replace "<tr>", "<tr bgcolor=red>"}else{$_}} > d:\get-service.html 結果如下圖所示 [本文被引用紀錄] http://blogs.msdn.com/powershell/archive/2007/01/06/cliff-notes-of-convertto-html-other-language-blogs.aspx 引用通告此日志的引用通告 URL 是: http://hung-yuwu.spaces.live.com/blog/cns!744FB258BF8C8020!1291.trak 引用此项的网络日志
|
|
|