Project

PSWriteHTML

Generate HTML reports, dashboards, and emails from PowerShell without writing HTML, CSS, or JavaScript.

Stars 1,019
Forks 115
Open issues 54
PowerShell Gallery downloads 7,576,901
Release v1.41.0
Language: PowerShell Updated: 2026-10-03
Command

New-HTML

Module PSWriteHTML

Building block for creating HTML elements. A starting point for all other cmdlets in PSWriteHTML except Out-HtmlView.

Syntax

New-HTML [-AddComment] [-Author <String>] [-AutoRefresh <Int32>] [-DateFormat <String>] [-Encoding <Object>] [-FavIcon <Uri>] [-FilePath <String>] [-Format] [[-HtmlData] <ScriptBlock>] [-Language <String>] [-Minify] [-Online] [-ShowHTML] [-Temporary] [-TitleText <String>] [-UseCssLinks] [-UseJavaScriptLinks] [<CommonParameters>]
#
Parameter set: All Parameter Sets

Examples

Authored help example

EXAMPLE 1

New-HTML {
    New-HTMLSection -HeaderText 'Donut Charts - Defaults' -CanCollapse {
        New-HTMLPanel {
            New-HTMLChart {
                New-ChartToolbar -Download
                #New-ChartBarOptions -Gradient
                New-ChartLegend -Name 'Time', 'Money', 'Taxes', 'test'
                New-ChartBar -Name 'Test' -Value 1, 2, 3, 0
                New-ChartBar -Name 'Test1' -Value 2, 5, 7, 0
                New-ChartBar -Name 'Test2' -Value 3, 1, 50, 5
            }
        }
        New-HTMLPanel {
            New-HTMLChart {
                New-ChartToolbar -Download
                #New-ChartBarOptions -Gradient
                New-ChartLegend -Name 'Time', 'Money', 'Taxes' -Color Red, Yellow, Green
                New-ChartBar -Name 'Test' -Value 1, 2, 3
                New-ChartBar -Name 'Test1' -Value 2, 5, 7
                New-ChartBar -Name 'Test2' -Value 3, 1, 2
            }
        }
        New-HTMLPanel {
            New-HTMLChart {
                New-ChartToolbar -Download
                New-ChartBarOptions -Type barStacked
                New-ChartLegend -Name 'Time', 'Money', 'Taxes' -Color Red, Yellow, Green
                New-ChartBar -Name 'Test' -Value 1, 2, 3
                New-ChartBar -Name 'Test1' -Value 2, 5, 7
                New-ChartBar -Name 'Test2' -Value 3, 1, 2
            }
        }
    }
} -ShowHTML -FilePath $PSScriptRoot\Example-ChartBarNext.html -Online -Format

EXAMPLE 2

New-HTML -TitleText "Testing HideButtons" -Online -FilePath "$PSScriptRoot\Example7_06.html" {
    # Hide Buttons
    New-HTMLSection -HeaderText "Hide Buttons" -Content {
        New-HTMLTable -DataTable $Table -HideButtons
    }
    New-HTMLSection -Invisible {
        New-HTMLSection -HeaderText "Hide Buttons" -Content {
            New-HTMLTable -DataTable $Table -HideButtons -Transpose
        }
        New-HTMLSection -HeaderText 'Some chart' {
            New-HTMLChart {
                New-ChartPie -Name 'Passed' -Value 5 -Color $ColorPassed
                New-ChartPie -Name 'Failed' -Value 10 -Color $ColorFailed
                New-ChartPie -Name 'Skipped' -Value 15 -Color $ColorSkipped
            }
        }
    }
    New-HTMLSection -HeaderText "Code used to generate above tables" -Content {
        New-HTMLCodeBlock {
            New-HTMLSection -HeaderText "Hide Buttons" -Content {
                New-HTMLTable -DataTable $Table -HideButtons
            }

New-HTMLSection -Invisible { New-HTMLSection -HeaderText "Hide Buttons" -Content { New-HTMLTable -DataTable $Table -HideButtons -Transpose } New-HTMLSection -HeaderText 'Some chart' { New-HTMLChart { New-ChartPie -Name 'Passed' -Value 5 -Color $ColorPassed New-ChartPie -Name 'Failed' -Value 10 -Color $ColorFailed New-ChartPie -Name 'Skipped' -Value 15 -Color $ColorSkipped } } } } } } -ShowHTML

Parameters

-AddComment SwitchParameter optional
Adds additional commands to the generated HTML file. This is useful for tracking or knowing what is what.
-Author String optional
Defines the author information in the HTML file (meta information). If not specified, the author information is skipped.
-AutoRefresh Int32 optional
Defines if the page should be refreshed automatically every X seconds.
-DateFormat String optional
Defines the date format in the HTML file (meta information). Default is 'yyyy-MM-dd HH:mm:ss'
-Encoding Object optional
Provides ability to choose encoding of the HTML file. Not really required to use, as UTF8 is the default. Options available: 'Unknown', 'String', 'Unicode', 'Byte', 'BigEndianUnicode', 'UTF8', 'UTF7', 'UTF32', 'Ascii', 'Default', 'Oem', 'BigEndianUTF32'
Possible values: Unknown, String, Unicode, Byte, BigEndianUnicode, UTF8, UTF7, UTF32, Ascii, Default, Oem, BigEndianUTF32
-FavIcon Uri optional
Provides ability to add a favicon to the HTML page. Can be a link or file path
-FilePath String optional
Provides the path to the file to be created.
-Format SwitchParameter optional
Formats HTML output (including CSS/JS). Requires PSParseHTML to be installed and available.
-HtmlData ScriptBlock optionalposition: 0aliases: Content
Provides ability to specify one or more elements within HTML. Using New-HTML without it, makes no larger sense.
-Language String optional
-Minify SwitchParameter optional
Minifies HTML output (including CSS/JS). Requires PSParseHTML to be installed and available.
-Online SwitchParameter optional
Enables or Disables linking of CSS/JS. When Online is enabled that means that the CSS/JS files are loaded from the CDN. When Online is disabled that means that the CSS/JS files are all loaded from same HTML file (making it very large).
-ShowHTML SwitchParameter optionalaliases: Open, Show
Opens HTML in browser when generating of HTML is done. When no filepath is provided it uses temporary path instead. Good for testing.
-Temporary SwitchParameter optional
Forces use of temporary file name. Doesn't work with -FilePath parameter.
-TitleText String optionalaliases: Name, Title
Title of the HTML page
Deprecated - will be removed

Common Parameters

This command supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable.

For more information, see about_CommonParameters.