Powershell: Passing calculated properties to ConvertTo-Html is broken

Created on 4 Jun 2018  路  3Comments  路  Source: PowerShell/PowerShell

Steps to reproduce

'one', 'two' | ConvertTo-Html -Property @{ l='Name'; e={ $_ } }

Expected behavior

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>HTML TABLE</title>
</head><body>
<table>
<colgroup><col/></colgroup>
<tr><th>Name</th></tr>
<tr><td>one</td></tr>
<tr><td>two</td></tr>
</table>
</body></html>

This is how it has always worked in Windows PowerShell.

The property name becomes the column header (th), and the values the column data (td).

Actual behavior

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>HTML TABLE</title>
</head><body>
<table>
<colgroup><col/></colgroup>
<tr><th>Name</th></tr>
<tr><td></td></tr>
<tr><td></td></tr>
</table>
</body></html>

Note how the <td> elements are unexpectedly empty.

Environment data

PowerShell Core v6.1.0-preview.2 on macOS 10.13.4
PowerShell Core v6.1.0-preview.2 on Ubuntu 16.04.4 LTS
PowerShell Core v6.1.0-preview.2 on Microsoft Windows 10 Pro (64-bit; Version 1709, OS Build: 16299.371)
Area-Cmdlets-Utility Issue-Bug Resolution-Fixed

Most helpful comment

@mklement0 If it's a regression then it's definitely a bug.

All 3 comments

/cc @SteveL-MSFT Can we consider this as bug?

@iSazonov:

To me the feature is (a) obviously broken in and of itself (I added a bit more detail) and (b) a regression from Windows PowerShell, so let me ask the opposite question: why _wouldn't_ this be a bug?

@mklement0 If it's a regression then it's definitely a bug.

Was this page helpful?
0 / 5 - 0 ratings