Friday, November 11, 2016

Powershell Out-GridView: Column title ending in slash ('/') causes values not to show

I was trying to spit out a DataTable in Out-GridView where the column headers happen to be URLs. I noticed that sometimes the values of the columns are not displaying in Out-GridView when the column title ends in a slash.

eg:

$dt = New-Object System.Data.DataTable
$dt.Columns.Add("ColumnA")
$dt.Columns.Add("ColumnB/")
$dt.Rows.Add("row1a", "row1b")
$dt | Format-Table -AutoSize
$dt | Out-GridView


The output of $dt | Format-Table -AutoSize is:

ColumnA ColumnB/
------- --------
row1a   row1b


The output of $dt | Out-GridView is:


It looks like there is a bug in GridView there. For now, I can append .Trim('/') to my column titles.

It looks like trailing whitespace is a problem too: https://windowsserver.uservoice.com/forums/301869-powershell/suggestions/11718579-out-gridview-fails-to-display-data-for-properties

No comments:

Post a Comment