Create table using HTML in Powershell

Question:

i want to know services stopped and which are set to automatic and output file goes to HTML page. In that HTML output i want to create table for stopped services on top of that table server name. Can someone tell me..

Answer:

Something like this should work.

Single table

Multiple tables

This version creates a sequence of tables using ConvertTo-Html -Fragment. Each table is preceded by a HTML header (h2 in the example) with the computer name. The individual tables are concatenated and merged into a single HTML document at the end using a bare (no input) call to ConvertTo-Html.

Styling

You’ll find the HTML generated by these to be pretty raw. One of the better ways to tackle that is to use CSS, here’s a fragment of mine that makes HTML tables look prettier:

Note: The Head only applies when the Fragment parameter is not supplied with ConvertTo-Html.

Source:

Create table using HTML in Powershell by licensed under CC BY-SA | With most appropriate answer!

Leave a Reply