All Projects → RamblingCookieMonster → PSHTMLTable

RamblingCookieMonster / PSHTMLTable

Licence: MIT license
PowerShell module to spice up ad hoc notifications and reports

Programming Languages

powershell
5483 projects

Projects that are alternatives of or similar to PSHTMLTable

Texreg
Conversion of R Regression Output to LaTeX or HTML Tables
Stars: ✭ 85 (+150%)
Mutual labels:  reporting, table
SCCM-Zone
My ♡ collection of PowerShell scripts and SCCM related stuff :)
Stars: ✭ 73 (+114.71%)
Mutual labels:  reporting
agel-table
element-ui table 的二次封装,保持灵活性,极简的思想,更少的代码,更多的功能,更快速的开发 ⬆⬆⬆
Stars: ✭ 26 (-23.53%)
Mutual labels:  table
mini-program-table
基于 WePY 实现的固定头和列的 table 组件,可根据自身需求进行修改扩展。
Stars: ✭ 14 (-58.82%)
Mutual labels:  table
maven-confluence-plugin
Maven plugin that generates project's documentation directly to confluence allowing to keep in-sync project evolution with its documentation
Stars: ✭ 56 (+64.71%)
Mutual labels:  reporting
CellReport
CellReport 是一个netcore实现的、以复杂统计报表为核心目标的制作、运行工具。支持数据看板、大屏制作。你可以使用数据库、excel文件、api服务、已有报表等为数据源,通过内置的集合函数组织数据,以类excel界面设计最终呈现结果。
Stars: ✭ 196 (+476.47%)
Mutual labels:  reporting
react-native-simple-table
A simple table for react native.
Stars: ✭ 32 (-5.88%)
Mutual labels:  table
datalist
Turns your data into a table with Relay Modern RefetchContainer
Stars: ✭ 12 (-64.71%)
Mutual labels:  table
terminal-columns
Render readable & responsive tables in the terminal
Stars: ✭ 27 (-20.59%)
Mutual labels:  table
projektor
View and share your test reports quickly and easily with Projektor
Stars: ✭ 36 (+5.88%)
Mutual labels:  reporting
BeeGridTable
BeeGridTable , is a Highly Customizable Table UI component library based on Vue.js. Rich functions、More efficient、Easy to use!
Stars: ✭ 45 (+32.35%)
Mutual labels:  table
data-11ty
An open source 11ty theme designed for reporting & data-visualization
Stars: ✭ 19 (-44.12%)
Mutual labels:  reporting
danger-swift-xcodesummary
A Danger-Swift plugin that adds build errors, warnings and unit tests results generated from xcodebuild to your Danger report
Stars: ✭ 72 (+111.76%)
Mutual labels:  reporting
vue3-table-lite
A simple and lightweight data table component for Vue.js 3. Features sorting, paging, row check, dynamic data rendering, supported TypeScript, and more.
Stars: ✭ 148 (+335.29%)
Mutual labels:  table
wikitable2csv
A web tool to convert Wiki tables to CSV 📈
Stars: ✭ 112 (+229.41%)
Mutual labels:  table
Table-Detection-using-Deep-Learning
Table Detection using Deep Learning
Stars: ✭ 24 (-29.41%)
Mutual labels:  table
python-realtime-table
Building realtime table using Python and Channels
Stars: ✭ 12 (-64.71%)
Mutual labels:  table
YNAB-reporter
Reporting system for You Need A Budget
Stars: ✭ 26 (-23.53%)
Mutual labels:  reporting
vue-table-for
Easily build a table for your records
Stars: ✭ 33 (-2.94%)
Mutual labels:  table
obj-to-table
Create a table from an array of objects
Stars: ✭ 15 (-55.88%)
Mutual labels:  table

PSHTMLTable

This is an old set of functions used to generate HTML tables, and highlight cells within them on demand.

One of PowerShell�s major strong points is its ability to interface with a variety of technologies and data sources. This makes it a great candidate for sending ad hoc notifications or generating HTML based reports. The attached functions can be used to spice up various notifications, reports, or other HTML generated by PowerShell.

A quick example showing a standard SCOM alert, and a SCOM alert generated using PSHTMLTable functions. The latter is a bit more helpful!

Plain SCOM Alert:

plain alert

PSHTMLTable SCOM Alert:

scom spicy

Instructions

# One time setup
    # Download the repository
    # Unblock the zip
    # Extract the PSHTMLTable folder to a module path (e.g. $env:USERPROFILE\Documents\WindowsPowerShell\Modules\)

    #Simple alternative, if you have PowerShell 5, or the PowerShellGet module:
        Install-Module PSHTMLTable

# Import the module.
    Import-Module PSHTMLTable    #Alternatively, Import-Module \\Path\To\PSHTMLTable

# Get commands in the module
    Get-Command -Module PSHTMLTable

Examples

Simple Example

This illustrates creating a webpage with several Process related stats, using all of the functions in PSHTMLTable

#gather 20 events from the system log and pick out a few properties
    $events = Get-EventLog -LogName System -Newest 20 | select TimeGenerated, Index, EntryType, UserName, Message

#Create the HTML table without alternating rows, colorize Warning and Error messages, highlighting the whole row.
    $eventTable = $events | New-HTMLTable -setAlternating $false |
        Add-HTMLTableColor -Argument "Warning" -Column "EntryType" -AttrValue "background-color:#FFCC66;" -WholeRow |
        Add-HTMLTableColor -Argument "Error" -Column "EntryType" -AttrValue "background-color:#FFCC99;" -WholeRow

#Build the HTML head, add an h3 header, add the event table, and close out the HTML
    $HTML = New-HTMLHead
    $HTML += "<h3>Last 20 System Events</h3>"
    $HTML += $eventTable | Close-HTML

#test it out
    set-content C:\test.htm $HTML
    & 'C:\Program Files\Internet Explorer\iexplore.exe' C:\test.htm

example output

Complex Example

This illustrates creating a webpage with several Process related stats, using all of the functions in PSHTMLTable

#This example demonstrates using the New-HTMLHead, New-HTMLTable, Add-HTMLTableColor, ConvertTo-PropertyValue and Close-HTML functions

#get processes to work with
    $processes = Get-Process

#Build HTML header
    $HTML = New-HTMLHead -title "Process details"

#Add CPU time section with top 10 PrivateMemorySize processes.  This example does not highlight any particular cells
    $HTML += "<h3>Process Private Memory Size</h3>"
    $HTML += New-HTMLTable -inputObject $($processes | sort PrivateMemorySize -Descending | select name, PrivateMemorySize -first 10)

#Add Handles section with top 10 Handle usage.
$handleHTML = New-HTMLTable -inputObject $($processes | sort handles -descending | select Name, Handles -first 10)

    #Add highlighted colors for Handle count

        #build hash table with parameters for Add-HTMLTableColor.  Argument and AttrValue will be modified each time we run this.
        $params = @{
            Column = "Handles" #I'm looking for cells in the Handles column
            ScriptBlock = {[double]$args[0] -gt [double]$args[1]} #I want to highlight if the cell (args 0) is greater than the argument parameter (arg 1)
            Attr = "Style" #This is the default, don't need to actually specify it here
        }

        #Add yellow, orange and red shading
        $handleHTML = Add-HTMLTableColor -HTML $handleHTML -Argument 1500 -attrValue "background-color:#FFFF99;" @params
        $handleHTML = Add-HTMLTableColor -HTML $handleHTML -Argument 2000 -attrValue "background-color:#FFCC66;" @params
        $handleHTML = Add-HTMLTableColor -HTML $handleHTML -Argument 3000 -attrValue "background-color:#FFCC99;" @params

    #Add title and table
    $HTML += "<h3>Process Handles</h3>"
    $HTML += $handleHTML

#Add process list containing first 10 processes listed by get-process.  This example does not highlight any particular cells
    $HTML += New-HTMLTable -inputObject $($processes | select name -first 10 ) -listTableHead "Random Process Names"

#Add property value table showing details for PowerShell ISE
    $HTML += "<h3>PowerShell Process Details PropertyValue table</h3>"
    $processDetails = Get-process powershell_ise | select name, id, cpu, handles, workingset, PrivateMemorySize, Path -first 1
    $HTML += New-HTMLTable -inputObject $(ConvertTo-PropertyValue -inputObject $processDetails)

#Add same PowerShell ISE details but not in property value form.  Close the HTML
    $HTML += "<h3>PowerShell Process Details object</h3>"
    $HTML += New-HTMLTable -inputObject $processDetails | Close-HTML

#write the HTML to a file and open it up for viewing
    set-content C:\test.htm $HTML
    & 'C:\Program Files\Internet Explorer\iexplore.exe' C:\test.htm

example output

Pester Example

# Invoke pester and store the results so that they can be referenced multiple times
$results = Invoke-Pester -show none -passthru

# Format cells where the value is greater than 0
$params = @{
    ScriptBlock = {$args[0] -gt 0}
}

# Create a summary table and add spaces into the column names for asthetics, adding colours for passed and failed tests
$summaryTable = $results | Select-Object `
     @{Name="Passed Count";Expression={$_.PassedCount}},
     @{Name="Failed Count";Expression={$_.FailedCount}},
     @{Name="Skipped Count";Expression={$_.SkippedCount}},
     @{Name="Pending Count";Expression={$_.PendingCount}},
     @{Name="Total Count";Expression={$_.TotalCount}} | New-HtmlTable |
    Add-HTMLTableColor -Argument "Failed" -Column "Failed Count" -AttrValue "background-color:#ffb3b3;" @params |
    Add-HTMLTableColor -Argument "Passed" -Column "Passed Count" -AttrValue "background-color:#c6ffb3;" @params

#Compose the html adding headers
$HTML = New-HTMLHead
$HTML += "<h3>Post Build Test Summary</h3>"
$HTML += $summaryTable
$HTML += "<h3>Post Build Test Results</h3>"

# Create a seperate table for each describe block
foreach ($section in ($results |Select-Object -ExpandProperty TestResult | Select-Object Describe -Unique)) {
    # Add a title based on the descibe block
    $HTML += ("<h4>{0}</h4>" -f $section.Describe)
    $HTML += $results | Select-Object -ExpandProperty TestResult | Where-Object -FilterScript { $_.Describe -eq $section.Describe } |
        Select-Object Context, Name, Result |
        New-HtmlTable |
            Add-HTMLTableColor -Argument "Failed" -Column "Result" -AttrValue "background-color:#ffb3b3;" |
            Add-HTMLTableColor -Argument "Passed" -Column "Result" -AttrValue "background-color:#c6ffb3;"
}

$HTML += "" | Close-HTML

#test it out
set-content C:\test.html $HTML
& 'C:\Program Files\Internet Explorer\iexplore.exe' C:\test.html

example output

Functions

PSHTMLTable includes several functions:

  • ConvertTo-PropertyValue - Convert an object with various properties into an array of property,value pairs
  • New-HTMLHead - Starts building HTML including internal style sheet (leaves body, html tags open)
  • New-HTMLTable - Create an HTML table from one or more objects
  • Add-HTMLTableColor - Colorize cells or rows in an HTML table, or add other inline CSS
  • CloseHTML - Close out the body and html tags

Notes

This was written during my early days with PowerShell - pull requests would be welcome!

For more details, stop by the old blog post on this!

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].