- Prison Code Breaker Diary -

=> aka: Nhật Kí Code Tù

Categories

It's a damn cool thing when you want to save something into HTML format.
Windows PowerShell provides this function through [ConvertTo-HTML] Cmdlets.

Example, if I want to save my list of current processes into HTML format

PS > Get-Process | ConvertTo-HTML | Out-File ProcessHTML.html

Another great thing is that it provides the way how you can format the output the HTML file through these 3 arguments: -head, -body, and -title.
Here, another example of formatting the output

$format_head = "<title> PROCESS LIST </title>"
$format_head += "<style>
"
$format_head += "TABLE { border-width:2px;border-style:solid}"
$format_head += "TH {border-width:1px;border-style:solid}"
$format_head += "TD {border-width:2px;border-style:solid}"
$format_head += "</style>"

$format_body = "<center> PROCESS LIST </center>"

Get-Process | ConvertTo-HTML -head $format_head -body $format_body | Out-File processHTML.html

0 comments

Post a Comment