Node JSPowerShellPSHTML

Experiment – Using PSHTML in node.js and host a Azure Web App

Is it possible to use PSHTML in node.js and host a site in Azure Web App? Yes, it is possible. Just a small tweak is needed and that is to upload the PSHTML module in project root folder. So, in Azure Web App the root folder path is like illustrated below


Here – PSHTML is our module to write HTML in PowerShell way!

Now, that I cleared the ground let us move on to the demo.


var express = require('express');
var router = express.Router();
var spawn = require('child_process').spawn;

router.use('/', function (req, res) {
    res.header('Content-Type', 'text/html;charset=utf-8');
    var child = spawn('powershell.exe',
    child.stdout.on('data', function (data) {

module.exports = router;


# Import-Module .\iAutomate\PSHTML\PSHTML\PSHTML.psd1
Import-Module "D:\home\site\wwwroot\PSHTML\PSHTML\PSHTML.psd1"
html -Content {
    head -Content {
        Title "iAutomate | PSHTML"
        Link -href "" -rel "stylesheet" -Integrity "sha384-GJzZqFGwb1QTTN6wy59ffF1BuGJpLSa9DkKMp0DgiMDm4iYMj70gZWKYbI706tWS" -CrossOrigin "anonymous"
        script -src "" -integrity "sha384-B0UglyR+jN6CkvvICOB2joaf5I4l3gm9GU6Hc1og6Ls7i6U/mkkaduKaBhlAXv9k" -crossorigin "anonymous"
        script -src "" -integrity "sha384-zDnhMsjVZfS3hiP7oCBRmfjkQC4fzxVxFhBx8Hkz2aZX8gEvA/jsP3eXRCvzTofP" -crossorigin "anonymous"
    body -Content {
        Div -Class "jumbotron" -Content {
            h1 -Class "display1" -Content "PSHTML Demo"
            p -Content "PSTHML ♥ PowerShell ♥ Azure Web App!"

Do you have questions like why not azure web jobs? why not pug? what not direct html? Feel free to connect with me and I am open to answer all your queries.

Enjoy PowerShell!

Leave a Reply

Your email address will not be published. Required fields are marked *