Node JSPowerShell

Conditional Check Using PUG | Get-Process | NODE JS and PowerShell

This blog post is to answer the question I received in my inbox as result of my previous System Information Web Apps using Node JS, PUG and PowerShell.

How to highlight table cells using PowerShell ? I wanted to show process information and if the handle is greater than 600, change the background as brown!

Yes, it’s possible in PowerShell but code may look bit cranky! Because we manipulate the data without the logic control. See the below sample code – Reference Link

Hold on! We don’t do this trick. Instead, we apply the logical calculation using PUG and a hint is below.

if (process.Handles > 600) // Is a simple way right?

We keep our PowerShell script clean and nifty as illustrated below

Which ultimately gives you the JSON output!

Now, parse the JSON in JS – The below snippet will help for that!

and style is yours! For a demo I used the below sample PUG (Works as expected)

Output is illustrated below!

Do you know? we can display boolean result using PUG as well! Here is the tip. Just try it!

Enjoy PowerShell!

Leave a Reply

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