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-HTMLText

Module PSWriteHTML

This function provides ability to add new text to the HTML file.

Syntax

New-HTMLText [-Alignment <left|center|right|justify>] [-BackGroundColor <String[]>] [-Color <String[]>] [-Direction <rtl|ltr>] [-Display <String[]>] [-FontFamily <String[]>] [-FontSize <Object[]>] [-FontStyle <normal|italic|oblique>] [-FontVariant <normal|small-caps>] [-FontWeight <String[]>] [-LineBreak] [-LineHeight <String[]>] [-Opacity <Double[]>] [-SkipParagraph] [-Text <String[]>] [[-TextBlock] <ScriptBlock>] [-TextDecoration <line-through|overline|underline>] [-TextTransform <uppercase|lowercase|capitalize>] [<CommonParameters>]
#
Parameter set: All Parameter Sets

Description

This function provides ability to add new text to the HTML file, with colors, fonts and other styling features. It is used to add text to the HTML file with proper styling and formatting. Please keep in mind that if parameter is not provided the defaults will be used. The defaults can be from the body itself, or from section or other parts of HTML depending on where the text is added.

Examples

Authored help example

EXAMPLE 1

New-HTML -TitleText 'This is a test' -FilePath "$PSScriptRoot\Example34_01.html" {
    New-HTMLHeader {
        New-HTMLText -Text "Date of this report $(Get-Date)" -Color Blue -Alignment right
    }
    New-HTMLMain {
        New-HTMLTab -TabName 'Test' {
            New-HTMLSection -HeaderText '0 section' {
                New-HTMLPanel {
                    New-HTMLTable -DataTable $Processes -HideFooter
                }
                New-HTMLPanel {
                    New-HTMLTable -DataTable $Processes -HideFooter
                }
                New-HTMLPanel {
                    New-HTMLTable -DataTable $Processes -HideFooter -Simplify
                }
                New-HTMLPanel {
                    New-HTMLTable -DataTable $Processes -HideFooter
                }
            }
        }
        New-HTMLTab -TabName 'Test5' {
            New-HTMLSection -HeaderText '1 section' {
                New-HTMLPanel {
                    New-HTMLTable -DataTable $Processes -HideFooter
                }
                New-HTMLPanel {
                    New-HTMLTable -DataTable $Processes -HideFooter
                    # New-HTMLTable -DataTable $Processes -HideFooter
                }
                New-HTMLPanel {
                    New-HTMLTable -DataTable $Processes -HideFooter
                }
            }
        }
    }
    New-HTMLFooter {
        New-HTMLText -Text "Date of this report $(Get-Date)" -Color Blue -Alignment right
    }
} -Online -ShowHTML

EXAMPLE 2

Parameters

-Alignment String[] optional
Provide alignment. When skipped the default alignment will be used. Options are: 'left', 'right', 'center', 'justify'
Possible values: left, center, right, justify
-BackGroundColor String[] optional
Pick one of the 800 colors or provide a hex color code.
-Color String[] optional
Pick one of the 800 colors or provide a hex color code.
-Direction String[] optional
Provide direction. When skipped the direction will not be changed. Options are: 'rtl','ltr'. By default it's 'ltr'.
Possible values: rtl, ltr
-Display String[] optional
Allows configuring CSS display property. The display property specifies the display behavior (the type of rendering box) of an element. Options are: 'none', 'inline', 'block', 'inline-block', 'contents','flex', 'grid', 'inline-flex', 'inline-grid', 'inline-table', 'list-item', 'run-in', 'table', 'table-caption', 'table-column-group', 'table-header-group', 'table-footer-group', 'table-row-group', 'table-cell', 'table-column', 'table-row'
Possible values: inline, block, inline-block, contents, flex, grid, inline-flex, inline-grid, inline-table, list-item, run-in, table, table-caption, table-column-group, table-header-group, table-footer-group, table-row-group, table-cell, table-column, table-row
-FontFamily String[] optional
Provide font family. When skipped the default font family will be used.
-FontSize Object[] optionalaliases: Size
Provide font size. When skipped the default font size will be used.
-FontStyle String[] optional
Provide font style. When skipped the default font style will be used. Options are: 'normal', 'italic', 'oblique'
Possible values: normal, italic, oblique
-FontVariant String[] optional
Provide font variant. When skipped the default font variant will be used. Options are: 'normal', 'small-caps'
Possible values: normal, small-caps
-FontWeight String[] optional
Provide font weight. When skipped the default font weight will be used. Options are: 'normal', 'bold', 'bolder', 'lighter', '100', '200', '300', '400', '500', '600', '700', '800', '900'
Possible values: normal, bold, bolder, lighter, 100, 200, 300, 400, 500, 600, 700, 800, 900
-LineBreak SwitchParameter optional
Decides whether to add line break at the end of the text or not.
-LineHeight String[] optional
Provide line height. When skipped the default line height will be used.
-Opacity Double[] optional
The opacity property sets the opacity level for an element. Value between 0 and 1. 1 is default.
-SkipParagraph SwitchParameter optional
Skips adding div tag to make sure text is not wrapped in it. By default it wraps all text in div tag.
-Text String[] optional
Provide text or text array to be added to the HTML file.
-TextBlock ScriptBlock optionalposition: 0
Defines ability to use text block instead of array
-TextDecoration String[] optional
Provide text decoration. When skipped the default text decoration will be used. Options are: 'none', 'line-through', 'overline', 'underline'
Possible values: line-through, overline, underline
-TextTransform String[] optional
Provide text transform. When skipped the default text transform will be used. Options are: 'uppercase', 'lowercase', 'capitalize'
Possible values: uppercase, lowercase, capitalize

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.