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

Module PSWriteHTML
Inputs
None. You cannot pipe objects to New-TableColumnOption
Outputs
PSCustomObject

Allows for certain modification of options within DataTable's columnDefs parameter. You can set visibility, searchability, sortability, and width for specific columns

Syntax

New-TableColumnOption -ColumnIndex <Int32[]> [-Hidden <Boolean>] [-Searchable <Boolean>] [-Sortable <Boolean>] [-Width <String>] [<CommonParameters>]
#
Parameter set: ColumnIndex
New-TableColumnOption -AllColumns [-Hidden <Boolean>] [-Searchable <Boolean>] [-Sortable <Boolean>] [-Width <String>] [<CommonParameters>]
#
Parameter set: AllColumns

Description

Allows for certain modification of options within DataTable's columnDefs parameter. See: https://datatables.net/reference/option/columnDefs

New-HTMLTable has parameters for -ResponsivePriorityOrder and -ResponsivePriorityOrderIndex and these are set at a higher precedent than options specified here. See the DataTable reference section for conflict resolution.

The New-TableColumnOption cmdlet will add entries to the columnDefs parameter in the order in which the cmdlets are ordered. If you use 2 or more New-TableColumnOption, the first cmdlet takes priority over the second cmdlet if they specify the same targets or overriding property values With this in mind, you should almost always specify -AllColumns last, since that will take priority over any commands issued later

Examples

Authored help example

EXAMPLE 1

New-TableColumnOption -ColumnIndex (0..4) -Width 50
The first 5 columns with have a width defined as 50, this may not be exact.
See: https://datatables.net/reference/option/columns.width

EXAMPLE 2

New-TableColumnOption -ColumnIndex 0,1,2 -Hidden $false
New-TableColumnOption -ColumnIndex 1 -Sortable $true
New-TableColumnOption -AllColumns -Hidden $true -Searchable $false -Sortable $false
All columns will be hidden, not searchable, and not sortable
However, since there is a option specified higher up, the first 3 columns will be visible
Additionally the 2nd column will be sortable

Parameters

-ColumnIndex Int32[] requiredaliases: Targetssets: ColumnIndex
Identifies specific columns that the properties should apply to
-Hidden Boolean optional
Defines if a column is hidden. A hidden column can still be used by Conditional Formatting and can still be searchable
-Searchable Boolean optional
Defines if a column is able to be searched
-Sortable Boolean optional
Defines if a column can be sorted
-Width String optional
Width for the column as a string
-AllColumns SwitchParameter requiredaliases: AllTargets, TargetAllsets: AllColumns
Uses the columnDef Target "_ALL" to indicate all columns / remaining columns

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.