ConvertTo-Html
Additional Resources for ConvertTo-Html |
Saving Data as an HTML File http://www.microsoft.com/technet/scriptcenter/topics/msh/cmdlets/convertto-html.mspx
|
SYNOPSIS
Creates an HTML page that represents an object or a set of objects.
SYNTAX
ConvertTo-Html [[-property] <Object[]>] [-inputObject <psobject>] [-body <string[]>] [-head <string[]>] [-title <string>] [<CommonParameters>]
DETAILED DESCRIPTION
Creates an HTML page that represents objects. The cmdlet returns a complete HTML page. The input objects are represented in a single HTML table within that page. The object property names appear as the HTML table column headings and each of the rows in the table list the corresponding property values. Properties without values are represented as blank cells in the table.
PARAMETERS
-inputObject <psobject>
Specifies the objects to represent as an HTML table. Enter a variable that contains the objects or type a command or expression that gets the objects.
Required? |
false |
Position? |
named |
Default value |
|
Accept pipeline input? |
true (ByValue) |
Accept wildcard characters? |
true |
-property <Object[]>
Specifies the properties of the input object to represent within the HTML table.
Required? |
false |
Position? |
1 |
Default value |
|
Accept pipeline input? |
false |
Accept wildcard characters? |
false |
-body <string[]>
Specifies the text to include within the <body> element of the HTML output.
Required? |
false |
Position? |
named |
Default value |
|
Accept pipeline input? |
false |
Accept wildcard characters? |
false |
-head <string[]>
Specifies the text to include within the <head> element of the HTML output.
Required? |
false |
Position? |
named |
Default value |
|
Accept pipeline input? |
false |
Accept wildcard characters? |
false |
-title <string>
Specifies the text to include within the <title> element of the HTML output.
Required? |
false |
Position? |
named |
Default value |
|
Accept pipeline input? |
false |
Accept wildcard characters? |
false |
<CommonParameters>
This cmdlet supports the common parameters: -Verbose, -Debug, -ErrorAction, -ErrorVariable, and -OutVariable. For more information, type, "get-help about_commonparameters".
INPUT TYPE
None
RETURN TYPE
Strings
NOTES
For more information, type "Get-Help ConvertTo-HTML -detailed". For technical information, type "Get-Help ConvertTo-HTML -full".
When specifying multiple values for a parameter, use commas to separate the values. For example, "<parameter-name> <value1>, <value2>".
EXAMPLE 1
get-date | convertto-html
This command uses the Get-Datecmdlet to create a DateTime object and pipe it to the ConvertTo-HTML cmdlet. The cmdlet creates an HTML page that includes an HTML table that represents the object. The HTML output is displayed at the console
EXAMPLE 2
get-date | convertto-html -title "Date Table" |
foreach { $_ -replace "><",">`n<" }
This command uses the Get-Datecmdlet to create DateTime object. It pipes the result to the ConvertTo-HTML cmdlet. Formatting instructions are applied by using the foreach-object cmdlet. It creates a tag set for each value in the DateTime object.
EXAMPLE 3
get-process | convertto-html -properties Name,Path,Company '
-title "Process Information" > proc.htm
invoke-item proc.htm
This command uses the Get-Processcmdlet to retrieve a set of objects that contain information about the processes running on the computer. It pipes those objects to the ConvertTo-HTML cmdlet, which creates an HTML page that includes an HTML table that represents the objects. The Properties parameter is used to specify the properties of the objects that are represented in the table. The Title parameter specifies the title of the HTML page. The redirection operator (>) is used to send the resulting HTML to a file named proc.htm. Finally, the Invoke-Itemcmdlet is used to open the proc.htm file in the application associated with the .htm file name extension.
RELATED LINKS