Skip to content

An HTML Table Module for displaying audit stats

Notifications You must be signed in to change notification settings

Merit-IT/HTMLTableModule

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

ConvertHtmlTable Module

A PowerShell module to convert objects to HTML tables with optional row coloring.

PowerShell

Overview

ConvertHtmlTable provides a simple way to convert PowerShell objects into HTML table markup. It supports dynamic row coloring through a special RowColour property.

Key Features

  • Converts any PowerShell object collection to HTML tables
  • Supports row-level CSS class styling via RowColour property
  • Lightweight and fast using StringBuilder
  • Easy one-liner installation from GitHub

Installation

Quick Install (One-Liner)

Run this in an elevated PowerShell window:

iex ((New-Object Net.WebClient).DownloadString('https://raw.githubusercontent.com/Merit-IT/HTMLTableModule/main/ConvertHtmlTable.ps1'))

Manual Install

  1. Download ConvertHtmlTable.psm1 and ConvertHtmlTable.psd1
  2. Copy to C:\Program Files\WindowsPowerShell\Modules\ConvertHtmlTable\1.0.0\
  3. Import the module:
    Import-Module ConvertHtmlTable -Force

Verify Installation

Get-Module ConvertHtmlTable -ListAvailable
Get-Command -Module ConvertHtmlTable

Usage

Basic Example

Import-Module ConvertHtmlTable

$data = @(
    [PSCustomObject]@{ Name = "Server01"; Status = "Online"; CPU = "45%" }
    [PSCustomObject]@{ Name = "Server02"; Status = "Offline"; CPU = "0%" }
    [PSCustomObject]@{ Name = "Server03"; Status = "Online"; CPU = "78%" }
)

$html = ConvertTo-ObjectToHtmlTable -Objects $data

Output:

<table><thead><tr><th>Name</th><th>Status</th><th>CPU</th></tr></thead><tbody><tr class=""><td>Server01</td><td>Online</td><td>45%</td></tr><tr class=""><td>Server02</td><td>Offline</td><td>0%</td></tr><tr class=""><td>Server03</td><td>Online</td><td>78%</td></tr></tbody></table>

Row Coloring

Add a RowColour property to apply CSS classes to individual rows:

$data = @(
    [PSCustomObject]@{ Name = "Server01"; Status = "Online"; RowColour = "success" }
    [PSCustomObject]@{ Name = "Server02"; Status = "Offline"; RowColour = "danger" }
    [PSCustomObject]@{ Name = "Server03"; Status = "Warning"; RowColour = "warning" }
)

$html = ConvertTo-ObjectToHtmlTable -Objects $data

The RowColour property is automatically excluded from the table output and applied as a CSS class to the <tr> element.

API Reference

ConvertTo-ObjectToHtmlTable

Converts a collection of objects to an HTML table string.

Parameters

Parameter Type Required Description
Objects List[Object] Yes Collection of objects to convert

Returns

String - HTML table markup

Updating

The installer automatically checks for newer versions. To update:

iex ((New-Object Net.WebClient).DownloadString('https://raw.githubusercontent.com/Merit-IT/HTMLTableModule/main/ConvertHtmlTable.ps1'))

About

An HTML Table Module for displaying audit stats

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors