Weekly Module Spotlight: PSHTML

Ever wanted to generate HTML documents dynamically? Until now, you had to statically code the HTML tags in the PowerShell scripts and ensure you open and close all needed HTML elements. Very cumbersome, tedious, and not very efficient.

Do that no more! PSHTML is here.

PSHTML is a cross platform Powershell module to generate HTML markup language within a DSL on Windows and Linux.

With PSHTML, you can write HTML documents the same way you write PowerShell scripts. You can use every possible language artifact and generate HTML code dynamically based on the input and context. Let us see a quick example!

Before you go forward and try out the example below, install the module from the PS Gallery.

This generates the following HTML text.

This is very easy. Let us give it some styles.

This results in a HTML page as shown below!

This is all good but very trivial. Let us try generating some tables and we will use bootstrap for styles.

This results in a nice table shown below!

See how easy was that!? I will stop this article here as this is not a PSHTML tutorial. Hope you have got a good idea about how useful the module is. There are several community members who did some great work with PSHTML. Check out their work as well.

About the author: Ravikanth C

Ravikanth is the founder and editor of the PowerShell Magazine. He is also a PowerShell MVP who works at Dell Inc. He blogs at http://www.ravichaganti.com/blog and you can follow him on Twitter @ravikanth.

Related Posts