Evotec

Project

PSWriteHTML

PSWriteHTML is an open-source PowerShell project with packages, release history, and working documentation.

Stars 995
Forks 114
Open issues 69
PowerShell Gallery downloads 7,436,513
Release v1.41.0
Language: PowerShell Updated: 2026-04-11

API Reference

Function

New-HTML

Namespace PSWriteHTML

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

Remarks

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

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

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.

Syntax

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

Parameters

AddComment SwitchParameter optionalposition: namedpipeline: False
Adds additional commands to the generated HTML file. This is useful for tracking or knowing what is what.
Author String optionalposition: namedpipeline: False
Defines the author information in the HTML file (meta information). If not specified, the author information is skipped.
AutoRefresh Int32 optionalposition: namedpipeline: False
Defines if the page should be refreshed automatically every X seconds.
DateFormat String optionalposition: namedpipeline: False
Defines the date format in the HTML file (meta information). Default is 'yyyy-MM-dd HH:mm:ss'
Encoding Object optionalposition: namedpipeline: Falsevalues: 12
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 optionalposition: namedpipeline: False
Provides ability to add a favicon to the HTML page. Can be a link or file path
FilePath String optionalposition: namedpipeline: False
Provides the path to the file to be created.
Format SwitchParameter optionalposition: namedpipeline: False
Formats HTML output (including CSS/JS). Requires PSParseHTML to be installed and available.
HtmlData ScriptBlock optionalposition: 0pipeline: Falsealiases: Content
Provides ability to specify one or more elements within HTML. Using New-HTML without it, makes no larger sense.
Language String optionalposition: namedpipeline: False
Minify SwitchParameter optionalposition: namedpipeline: False
Minifies HTML output (including CSS/JS). Requires PSParseHTML to be installed and available.
Online SwitchParameter optionalposition: namedpipeline: False
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 optionalposition: namedpipeline: Falsealiases: 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 optionalposition: namedpipeline: False
Forces use of temporary file name. Doesn't work with -FilePath parameter.
TitleText String optionalposition: namedpipeline: Falsealiases: Name, Title
Title of the HTML page
UseCssLinks SwitchParameter optionalposition: namedpipeline: False
Deprecated - will be removed
UseJavaScriptLinks SwitchParameter optionalposition: namedpipeline: False