Skip to content

Instantly share code, notes, and snippets.

Last active August 14, 2023 00:41
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?

Rendering PowerShell terminal output as HTML

When I run this PowerShell script:

the output looks as follows:


In order to share the results with others, I convert the output to HTML. The resulting page looks like this:


Here's a link to that page:

Here's how the HTML is generated.

Here is It takes case of running the script inside screen (to provide a terminal to the underlying process):


cd /var/www/

screen -d -m ./

Here is


cd /var/www/

script -q -c 'pwsh -Command ./net-liquidity-earnings-remittances.ps1 -display_chart_url -save_iframe' script-out-nl

cat script-out-nl |
    /home/dharmatech/go/bin/terminal-to-html -preview |
    sed 's/pre-wrap/pre/' |
    sed 's/terminal-to-html Preview/Net Liquidity Table/' |
    sed 's/<body>/<body style="width: fit-content;">/' > ../reports/net-liquidity-table.html

mv net-liquidity-chart.html  ../reports
mv spx-fair-value-chart.html ../reports

It does the following:


This script is to run Mon-Fri at 10:20 eastern and 1:05 PM eastern. It should also run on Thur at 1:45 PM eastern. Here are the crontab entries for this:

20 10 * * MON-FRI /var/www/
 5 13 * * MON-FRI /var/www/
45 13 * * THU     /var/www/

Video demonsration

Here's a short video walking through some of this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment