CmdID

CmdID / PowerShell / Cmdlets / ConvertTo

ConvertTo-Html

Converts .NET objects into HTML that can be displayed in a Web browser. PowerShell reference

From the PowerShell reference 10 parameters

Opens CmdID with your command, read as PowerShell. It is read in your browser and sent nowhere.

What it does

from the PowerShell reference, CC BY 4.0

Converts .NET objects into HTML that can be displayed in a Web browser. The ConvertTo-Html cmdlet converts .NET objects into HTML that can be displayed in a Web browser. You can use this cmdlet to display the output of a command in a Web page. You can use the parameters of ConvertTo-Html to select object properties, to specify a table or list format, to specify the HTML page title, to add text before and after the object, and to return only the table or list fragment, instead of a strict DTD page. When you submit multiple objects to ConvertTo-Html, PowerShell creates the table (or list) based on the properties of the first object that you submit. If the remaining objects do not have one of the specified properties, the property value of that object is an empty cell. If the remaining objects have additional properties, those property values are not included in the file.

ConvertTo-Html [-InputObject <PSObject>] [[-Property] <Object[]>] [[-Body] <String[]>] [[-Head] <String[]>] [[-Title] <String>] [-As <String>] [-CssUri <Uri>] [-PostContent <String[]>] [-PreContent <String[]>] [<CommonParameters>]
ConvertTo-Html [-InputObject <PSObject>] [[-Property] <Object[]>] [-As <String>] [-Fragment] [-PostContent <String[]>] [-PreContent <String[]>] [<CommonParameters>]

Create a web page to display the date

ConvertTo-Html -InputObject (Get-Date)Identify

Create a web page to display PowerShell aliases

Get-Alias | ConvertTo-Html | Out-File aliases.htm Invoke-Item aliases.htmIdentify

Create a web page to display PowerShell events

Get-EventLog -LogName "Windows PowerShell" | ConvertTo-Html | Out-File pslog.htmIdentify

Trips 2 Sigma rules: mediumEventLog Query Requests By Builtin Utilities by Ali Alwashali, Nasreddine Bencherchali (Nextron Systems); mediumPotentially Suspicious EventLog Recon Activity Using Log Query Utilities by Nasreddine Bencherchali (Nextron Systems), X__Junior (Nextron Systems)

Create a web page to display processes

Get-Process | ConvertTo-Html -Property Name, Path, Company -Title "Process Information" | Out-File proc.htm Invoke-Item proc.htmIdentify

Create a web page to display service objects

Get-Service | ConvertTo-Html -CssUri "test.css"Identify

Create a web page to display service objects

Get-Service | ConvertTo-Html -As List | Out-File services.htmIdentify

Create a web table for the current date

Get-Date | ConvertTo-Html -FragmentIdentify

Create a web page to display PowerShell events

Get-EventLog -Log "Windows PowerShell" | ConvertTo-Html -Property Id, Level, TaskIdentify

Trips 2 Sigma rules: mediumEventLog Query Requests By Builtin Utilities by Ali Alwashali, Nasreddine Bencherchali (Nextron Systems); mediumPotentially Suspicious EventLog Recon Activity Using Log Query Utilities by Nasreddine Bencherchali (Nextron Systems), X__Junior (Nextron Systems)

Create a web page to display specified services

$htmlParams = @{ Title = "Windows Services: Server01" Body = Get-Date PreContent = " Generated by Corporate IT " PostContent = "For details, contact Corporate IT." } Get-Service A* | ConvertTo-Html @htmlParams | Out-File Services.htm Invoke-Item Services.htmIdentify

Its page in the reference: ConvertTo-Html.

Parameters

10 in the PowerShell reference
-AsDetermines 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.
-BodySpecifies the text to add after the opening <BODY> tag. By default, there is no text in that position.
-CssUriSpecifies 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.
-FragmentGenerates only an HTML table. The <HTML>, <HEAD>, <TITLE>, and <BODY> tags are omitted.
-HeadSpecifies the content of the <HEAD> tag. The default is <title>HTML TABLE</title>. If you use the Head parameter, the Title parameter is ignored.
-InputObjectSpecifies 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, ConvertTo-Html creates a table that displays the properties of a collection or of an array of objects. To create a table of the individual objects, use the pipeline operator to pipe the objects to ConvertTo-Html.
-PostContentSpecifies text to add after the closing </TABLE> tag. By default, there is no text in that position.
-PreContentSpecifies text to add before the opening <TABLE> tag. By default, there is no text in that position.
-PropertyIncludes 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 scriptblock or a hash table. Valid key-value pairs are: - Expression - <string> or <scriptblock> - FormatString - <string> - Width - <int32> - must be greater than 0 - Alignment - value can be Left, Center, or Right For more information, see about_Calculated_Properties.
-TitleSpecifies a title for the HTML file, that is, the text that appears between the <TITLE> tags.