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

Module PSWriteHTML

Creates a new HTML section with customizable styling options.

Syntax

New-HTMLSection [-AlignContent <String>] [-AlignItems <stretch|flex-start|flex-end|center|baseline>] [-AnchorName <String>] [-BackgroundColor <String>] [-BorderRadius <String>] [-CanCollapse] [-Collapsed] [[-Content] <ScriptBlock>] [-Density <Spacious|Comfortable|Compact|Dense|VeryDense>] [-Direction <row|row-reverse|column|column-reverse>] [-HeaderBackGroundColor <String>] [-HeaderText <String>] [-HeaderTextAlignment <center|left|right|justify>] [-HeaderTextColor <String>] [-HeaderTextSize <String>] [-Height <Object>] [-Invisible] [-IsHidden] [-JustifyContent <flex-start|flex-end|center>] [-Margin <Object>] [-StyleSheetsConfiguration <IDictionary>] [-Width <Object>] [-Wrap <wrap|nowrap|wrap-reverse>] [<CommonParameters>]
#
Parameter set: All Parameter Sets

Description

The New-HTMLSection function creates a new HTML section with various customizable styling options such as text alignment, background color, flexbox properties, and more.

Examples

Authored help example

EXAMPLE 1

New-HTMLSection -Content { "This is the content of the section." } -HeaderText "Section Title" -HeaderTextColor "blue" -HeaderTextSize "20px" -HeaderTextAlignment "center" -HeaderBackGroundColor "lightgray" -BackgroundColor "white" -CanCollapse -Height "200px" -Width "50%" -Wrap "wrap" -Direction "row" -AlignContent "center" -AlignItems "center" -JustifyContent "flex-start" -BorderRadius "10px" -AnchorName "section1" -StyleSheetsConfiguration @{ Section = 'customSection'; SectionText = 'customSectionText' }

EXAMPLE 2

New-HTMLSection -HeaderText "Cards with Responsive Layout" -Density Comfortable {
    New-HTMLInfoCard -Title "Card 1" -Number 100 -Icon "๐Ÿ“Š"
    New-HTMLInfoCard -Title "Card 2" -Number 200 -Icon "๐Ÿ“ˆ"
    # Cards will automatically wrap and maintain comfortable spacing
}

EXAMPLE 3

$content = {
    "This is a sample content."
}
New-HTMLSection -Content $content -HeaderText "Sample Section" -HeaderTextColor "red" -HeaderTextSize "18px" -HeaderTextAlignment "left" -HeaderBackGroundColor "lightblue" -BackgroundColor "lightyellow" -Height "150px" -Wrap "nowrap" -Direction "column" -AlignContent "flex-start" -AlignItems "flex-start" -JustifyContent "center" -BorderRadius "5px" -AnchorName "sampleSection" -StyleSheetsConfiguration @{ Section = 'customSection'; SectionText = 'customSectionText' }

Parameters

-AlignContent String optional
Specifies the align-content property. Valid values are 'flex-start', 'flex-end', 'center', 'space-between', 'space-around', 'stretch'.
Possible values: flex-start, flex-end, center, space-between, space-around, stretch
-AlignItems String optional
Specifies the align-items property. Valid values are 'stretch', 'flex-start', 'flex-end', 'center', 'baseline'.
Possible values: stretch, flex-start, flex-end, center, baseline
-AnchorName String optional
Specifies the anchor name for the section.
-BackgroundColor String optionalaliases: BackgroundShade
Specifies the background color of the section.
-BorderRadius String optional
Specifies the border radius of the section. Valid values are '0px', '5px', '10px', '15px', '20px', '25px'.
Possible values: 0px, 5px, 10px, 15px, 20px, 25px
-CanCollapse SwitchParameter optionalaliases: Collapsable
Indicates whether the section can be collapsed.
-Collapsed SwitchParameter optional
Indicates whether the section is collapsed.
-Content ScriptBlock optionalposition: 0
Specifies the content of the HTML section as a ScriptBlock.
-Density String optional
Specifies the density of the panel. This will automatically enable responsive wrapping for the panel. The options are: Spacious, Comfortable, Compact, Dense, VeryDense.
Possible values: Spacious, Comfortable, Compact, Dense, VeryDense
-Direction String optional
Specifies the flex-direction property. Valid values are 'row', 'row-reverse', 'column', 'column-reverse'.
Possible values: row, row-reverse, column, column-reverse
-HeaderBackGroundColor String optionalaliases: TextBackGroundColor
Specifies the background color of the header.
-HeaderText String optionalaliases: Name, Title
Specifies the header text of the section.
-HeaderTextAlignment String optionalaliases: TextAlignment
Specifies the text alignment of the header. Valid values are 'center', 'left', 'right', 'justify'.
Possible values: center, left, right, justify
-HeaderTextColor String optionalaliases: TextColor
Specifies the text color of the header.
-HeaderTextSize String optionalaliases: TextSize
Specifies the text size of the header.
-Height Object optional
Specifies the height of the section.
-Invisible SwitchParameter optional
Indicates whether the section is invisible.
-IsHidden SwitchParameter optional
Indicates whether the section is initially hidden.
-JustifyContent String optional
Specifies the justify-content property. Valid values are 'flex-start', 'flex-end', 'center'.
Possible values: flex-start, flex-end, center
-Margin Object optional
Specifies the margin of the section.
-StyleSheetsConfiguration IDictionary optional
Specifies the configuration for style sheets.
-Width Object optional
Specifies the width of the section. Default value is '100%'.
-Wrap String optional
Specifies the flex-wrap property. Valid values are 'wrap', 'nowrap', 'wrap-reverse'.
Possible values: wrap, nowrap, wrap-reverse

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.