Hướng dẫn dùng convertto-html JavaScript
Skip to main content This browser is no longer supported. Show
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
ConvertTo-Html
Converts .NET objects into HTML that can be displayed in a Web browser. In this articleSyntax
DescriptionThe You can use the parameters of When you submit multiple objects to ExamplesExample 1: Create a web page to display the date
This command creates an HTML page that displays the properties of the current date. It uses the InputObject parameter to submit
the results of a Example 2: Create a web page to display PowerShell aliases
This command creates an HTML page that lists the PowerShell aliases in the current console. The command uses the Example 3: Create a web page to display PowerShell events
This command creates an HTML page called It uses the The command also uses the Example 4: Create a web page to display processes
These commands create and open an HTML page that lists the name, path, and company of the processes on the local computer. The first command uses the The command uses the Property parameter to select three properties of the process objects to be included in the table. The command uses the Title parameter to specify a title for the HTML page. The command also uses the The second command uses the Example 5: Create a web page to display service objects
This command creates an HTML page of the service objects that the The CssUri parameter adds an additional Example 6: Create a web page to display service objects
This command creates an HTML page of the service objects that the Example 7: Create a web table for the current date
This command uses The Example 8: Create a web page to display PowerShell events
This command uses the It uses a pipeline operator ( The Example 9: Create a web page to display specified services
This command creates and opens a Web page that displays the services on the computer that begin with The first part of the command uses the A semicolon ( Example 10: Set the Meta properties and Charset of the HTML
This command creates the HTML for a webpage with the meta tags for refresh, author, and keywords. The charset for the page is set to UTF-8 Example 11: Set the HTML to XHTML Transitional DTD
This command sets the ParametersDetermines whether the object is formatted as a table or a list. Valid values are Table and List. The default value is Table. The Table value generates an HTML table that resembles the PowerShell table format. The header row displays the property names. Each table row represents an object and displays the object's values for each property. The List value generates a two-column HTML table for each object that resembles the PowerShell list format. The first column displays the property name. The second column displays the property value.
Specifies the text to add after the opening
Specifies text to add to the opening This parameter was introduced in PowerShell 6.0.
Specifies the Uniform Resource Identifier (URI) of the cascading style sheet (CSS) that is applied to the HTML file. The URI is included in a style sheet link in the output.
Generates only an HTML table. The
Specifies the content of the
Specifies the objects to be represented in HTML. Enter a variable that contains the objects or type a command or expression that gets the objects. If you use this parameter to submit multiple objects, such as all of the services on a computer,
Specifies text to add to the opening This parameter was introduced in PowerShell 6.0.
Specifies text to add after the closing |
Type: | String[] |
Position: | Named |
Default value: | None |
Accept pipeline input: | False |
Accept wildcard characters: | False |
Specifies text to add before the opening Includes the specified properties of the objects in the HTML. The value of the Property parameter can be a new calculated property. The calculated property can be a script block or a hash table. Valid key-value pairs are: For more information, see about_Calculated_Properties. Specifies a title for the HTML file, that is, the text that appears between the Changes the This parameter was introduced in PowerShell 6.0. PSObject You can pipe any .NET object to System.String or System.Xml.XmlDocument To use this cmdlet, pipe
one or more objects to the cmdlet or use the InputObject parameter to specify the object. When the input consists of multiple objects, the output of these two methods is quite different. When you pipe multiple objects to a cmdlet, PowerShell sends the objects to the cmdlet one at a time. As a result, When you use the InputObject parameter to submit multiple objects, To comply with the XHTML Strict DTD, the
Submit and view feedback for tag. By default, there is no text in that position.
Type:
String[]
Position:
Named
Default value:
None
Accept pipeline input:
False
Accept wildcard characters:
False
Name
(or label) -
(added in PowerShell 6.x)Expression
-
or FormatString
- Width
-
- must be greater than 0
Alignment
- value can be
Left
, Center
, or Right
Type:
Object[]
Position:
0
Default value:
None
Accept pipeline input:
False
Accept wildcard characters:
False
tags.Type:
String
Position:
2
Default value:
None
Accept pipeline input:
False
Accept wildcard characters:
False
DOCTYPE
to XHTML Transitional DTD, Default DOCTYPE
is XHTML Strict DTD.Type:
SwitchParameter
Position:
Named
Default value:
None
Accept pipeline input:
False
Accept wildcard characters:
False
Inputs
ConvertTo-Html
.Outputs
ConvertTo-Html
returns series of strings that comprise valid HTML.Notes
ConvertTo-Html
creates a table that displays the individual objects. For example, if you pipe the processes on a computer to ConvertTo-Html
, the resulting table displays all of
the processes.ConvertTo-Html
receives these objects as a collection or as an array. As a result, it creates a table that displays the array and its properties, not the items in the array. For example, if you use InputObject to submit the processes on a computer to ConvertTo-Html
, the resulting table displays an object array and its properties.DOCTYPE
tag is modified accordingly:Feedback