I'm stumped on this one. I have a PS custom object with strings only and I want to build a report where I'm outputting strings of data into a new pipeline output object.
$myObjectTable |
Select-Object @{
n = "OldData";
e = {
$_ | Select-Object name, *_old | Format-List | Out-String
}
},
@{
n = "NewData";
e = {
$_ | Select-Object name, *_new | Format-List | Out-String
}
}
Running this produces blank output.
I tried running the code above with just the $_ object in the expressions, but I only got ... as the output. Wrapping the expressions in parenthesis did not change the output.
The
...
as property value means that the value is either a multi-line string or it just didn't fit in a tabular format. See Using Format commands to change output view more details.You can fix those empty lines added by
Out-String
usingTrim
. Then if you want to properly display this object having multi-line property values,Format-Table -Wrap
will be needed.Here is a little example:
Resulting object would become: