Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
95 lines (80 sloc) 4.89 KB
A PowerShell module with cmdlets to create partial- or full HTML output
with table(s) of data from data in a PowerShell session, and that provides
some additional functionality and features beyond the wonderful
ConvertTo-Html cmdlet.
This module provides cmdlets for creating HTML to represent in table
format the given data from a PowerShell session. While it does leverage
ConvertTo-Html for the some of the final output, the module provides
additional functionality by allowing for "highlighting" of desired rows,
and for handling number formatting in the form of rounding, so as to
remove the bit of additional work anytime a user wants to round values for
eventual output.
The module leverages the jQuery framework and the TableSorter jQuery plugin
for making consistent, usable table layouts for your data. The module
expects that these JavaScript files are hosted centrally (anywhere
accessible via the resulting HTML code), which allows for the generated
HTML output to simply link to the JavaScript libraries, instead of needing
to embed the JavaScript code into each output file.
The module supports configuration through a pair of cmdlets and by using
JSON-data file for persisting configuration values. The default
configuration is loaded into the current PowerShell session at the first
module import time. Two configuration scopes exist: AllUsers and
The Session scope is the scope from the module's main cmdlets get their
configuration values. The very first use of the newly obtained module
has both the Session and AllUsers scopes with the same values. Changing
a Session-scoped configuration value sets that desired value for the
duration of the PowerShell session, only.
The AllUsers scope is the scope that persists across PowerShell
sessions. When the consumer sets a configuration value in the AllUsers
scope, this updated AllUsers configuration is written to the JSON file
in the module's filesystem directory. This expects that the consumer
has Write rights to said directory. Changing a configuration item in
the AllUsers scope will not affect the configuration for the current
PowerShell session.
To update the configuration values both in the current PowerShell
session and for all subsequent PowerShell sessions, one should specify
both the Session and AllUsers scopes when using the
Set-NewHtmlReportConfiguration cmdlet.
The consumer of this module can either leverage the default content
delivery network (CDN) locations of the JavaScript/CSS files, or can
choose to host the pertinent resource files on their web server in the
appropriate locations (the locations that they specified in the module
The cmdlets in this module are useful for creating HTML for either full
web pages, or for creating the table HTML for use in some other HTML
document. The full web pages are complete with code that will include
the JavaScript libraries and CSS style files from the configured web
server. The table HTML is ready to be added to the body of such an HTML
document, but does not include the code to refer to these library- and
style files. This is useful for when you want to build more than one
table to include in your full HTML page.
These cmdlets make it easy to round numeric values of properties with
just the flick of a switch parameter. By using this switch parameter,
the cmdlet will round any numeric values to the specified number of
decimal places. This makes it oh so easy to tidy up the values where you
don't need, say, thirteen decimal places of precision, and without
needing to add any numeric formatting handling to your PowerShell before
sending the objects to the NewHtmlReport module's cmdlets.
An additional feature is the ability to "highlight" desired rows of
data. Say, a row whose object has a property that exceeds a certain
value threshold (like, a datastore whose used capacity is over some given
percentage), or that has a property that is not a standard, desired value
(like, a VMHost whose connection status is something other than,
"Connected"). This is handled by adding a particular property to any
input object whose row you wish to hightlight in this way. See the
examples in the cmdlets' help for illustrations of how to utilize this
All of the cmdlets have help and examples built in. For help on a specific
cmdlet, use the normal route of "Get-Help -Full New-<someCmdlet>".
HtmlReport, NewHtmlReport
The GitHub site from which you got this PSModule, or