Concerning ConvertTo-Html

Hello Community :wink:

I’m trying to format an output of the script and came across the ConvertTo-HTML cmdlet.

This is my code.

$a01 = "abc"
$a02 = "def"
-join ($a01, $a02)
-join ($a02, $a01)

I need to get the HTML table like this as an output of the script.

---------------
| abc |  def |
----------------
| def | abc |
-------------

Is that possible?

The ConvertTo-Html cmdlet works best with custom objects.

Example:

$a01 = "abc"
$a02 = "def"

@(
    [PSCustomObject]@{
        Column1 = $a01
        Column2 = $a02
    }
    [PSCustomObject]@{
        Column1 = $a02
        Column2 = $a01
    }
) | ConvertTo-Html -Fragment

Thanks, Daniel!