The Surly Admin

Father, husband, IT Pro, cancer survivor

New Module Published: PSHTMLTools

Before I get started, just wanted to check with you that you’re ok?  It’s been a long time since I posted here and it probably came as a shock.  Work at athenahealth has been incredibly challenging and to be honest, when I get home I just want to spend time with my family and not hours MORE behind the keyboard coding!  I’ve also taken up hiking–when my back allows–and am the proud owner of a blue Tesla Model 3!  And, in a stunning turn of events, my daughter has become a teenager.  I have no idea how that happened.  That said, I got the bug this weekend after a Github contributor put in a Pull Request to my old Set-CellColor function.  I wish I could have accepted the PR, but I ended up reworking the script to squash a long standing bug.  Then I added CI/CD and Pester testing.  Ah, screw it, let’s make a module!!

Introducing PSHTMLTools

This is a module of the 3 HTML tools I use–almost exclusively–for my reporting at work.  They are designed to work with ConvertTo-HTML, and while they might work with HTML tables created from another source, it’s not their purpose.  The 3 functions, you ask?

  1. Set-AlternatingRow
    • This is a simple function that will alternate between two CSS classes for each row of a table.  You supply the CSS and the classes and just tell the function what they are.
  2. Set-CellColor
    • This function will take a Filter that you supply (Column4 -eq 5) and if it finds a cell in that column that matches your criteria will change its color to what you tell it to.  This is great for reports where you want to highlight when some threshold is crossed, like 90% license usage.
  3. Set-GroupRowColorsByColumn
    • This will change the color of a row whenever the value of a column changes value.  Say you have a report that has 2 or 3 lines for each server, you’d group by the server name and get a different color every time the report moves on to a new server.  This one makes for especially slick looking reports.

That’s it.  I enjoyed making a full CI/CD pipeline for this module with a full suite of Pester tests and automatic publishing to PSGallery.  To install it you can simply install it from the PowerShell Gallery:

Interested in contributing? You can find the project on Github here.

 

February 25, 2019 Posted by | PowerShell - HTML Reporting | | 1 Comment

HTML Reporting – Grouping Rows

Continuing my HTML reporting series, I have a new twist on coloring columns.  There are times when you want to group a number of rows together, so I created this function to do just that.  It’s essentially a riff on the Set-AlternatingRows with a little bit of Set-CellColor thrown into the mix.

Continue reading

March 24, 2015 Posted by | PowerShell - HTML Reporting | , | 1 Comment

New Scripts – Bandwidth Report and Google Charts

Got a couple of new scripts I recently wrote, here’s some quick thoughts on them.

Continue reading

April 2, 2014 Posted by | PowerShell - HTML Reporting | , , , , , | 4 Comments

HTML Reporting – A Simple Cell Color Changer

As a follow-up to the ConvertTo-AdvHTML function, I have also written a much simpler version that simply changes the color of a cell.  The advantage to this script over the bigger ConvertTo-AdvHTML function is it works with current ConvertTo-HTML, or even HTML pages from other sources.  It also allows you the ability to set the criteria for the the color change.  Best of all it’s simple to use.

Continue reading

March 3, 2014 Posted by | PowerShell - HTML Reporting | , | 19 Comments

ConvertTo-AdvHTML – New Advanced Function for HTML Reporting

I love using ConvertTo-HTML.  There, I’ve said it.  The vast number of scripts I write are doing some kind of reporting function and the ability to create simple, fast, yet good looking reports with HTML has been a huge plus for PowerShell.  That said though, there’s definitely room for improvement.  ConvertTo-AdvHTML is an advanced function that addresses some of the current limitations with current cmdlet.  But this blog post isn’t going to a long explanation of how to use the new cmdlet, instead I wanted to write a script that actually used it.

Continue reading

February 27, 2014 Posted by | PowerShell - HTML Reporting | , , , , | 14 Comments

How to Create HTML Reports

Find yourself creating reports in Powershell and wished they looked a little more presentable than a CSV file?  Send regular reports to your manager and want it to look professional?  Here are some technique’s I’ve developed that produce some pretty sharp reports in HTML using standard Powershell cmdlets (plus one function to pretty up your tables).

Continue reading

January 21, 2013 Posted by | PowerShell - HTML Reporting | , , , | 10 Comments