Introducing PSHTML


In this blog post, I would like to introduce a project on which I have been spending quite some time: PSHTML.

I also want to announce that I have made the module availble on the PowerShell Gallery.

Anyone can download it, using the following simple command:


PSHTML in a few words

PSHTML is a DSL (Domain Specific Language) which allows one to create webpages without leaving your Powershell script.

I understand that this can be a bit vague, so let’s showcase this using an example:

It generates the following HTML code:

This looks pretty simple, right. You can actaully reproduce an HTML scructure document using only PowerShell syntax.

This is a pretty straight forward example, on some of the most basic HTML tags. But, the PSHTML module actually comes with (almost) all the HTML Tags available.

Now, the big advantage of this, is as this is the PowerShell language, you benefit from all the ‘syntaxic’  confort of the language. This means, that PSHTML integrates very nicley with any of the powershell operators, loops etc…

In the following example, we created listed all our favorite languages, by creating an array and looping through it using a foreach .



But that’s not all. I have also built in a ‘templating’ mechanism, where you could create your header and footer once, and re-use on all your pages, as in the example below:

Assiming that body/footer are files located in /templates/body.ps1 | /templates/Footer.ps1


I invite you to read more about the PSHTML project, by heading to the repository hosted on github.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.