PSWriteHTML
PSWriteHTML copied to clipboard
Transpose Parameter for Out-HtmlView?
When sending data (aka a PS Object) to Out-HtmlView I want to transpose rows into columns. Is this possible with the current module's version?
E. g.: Form Exchange Shell I saved the result from 'Get-SendConnector' to XML. Now I import that file into $Q: '$q1=Import-Clixml -LiteralPath .\SendConnector.xml'
The result looks like this
.
The attributes of the two connectors are in rows below each other and the table has many columns next to each other. But I would have liked to swap: the connectors (in the example here there are two) next to each other in columns and the attributes below each other.
As a workaround, I open the table as an Excel file, copy the rows and paste them in a new sheet using the transpose function. This then looks like this:

I need this quite often. It would be nice if this function was available directly in the module.
Out-HtmlView -Transpose is it not working?
Oh - my bad. I overlooked this parameter. Sorry! But when I use Out-HtmlView with -Transpose I can only see the first connector and the second one is not shown.

When I use -FlattenObject too the result is quite weird or mixed.

I guess my implementation of it is incorrect or was approached for showing a single object transposed. To transpose correctly more than 1 object you would need to provide a way to define column names (object names). You have picked X and Y yourself.
Maybe this helps. I just noticed that the second object is included in the output after all. But not in another column as expected. The second object is below the first one and all row labels are repeated. Here is an example for Get-ExchangeCertificate:

I guess my implementation of it is incorrect or was approached for showing a single object transposed. To transpose correctly more than 1 object you would need to provide a way to define column names (object names). You have picked X and Y yourself.
Not quite. X and Y are the anonymized names of the connectors. I copied this information manually to the top to improve readability for me. In the original output the first line contains the name of the first attribute of the object. DNSRoutingEnabled' in the case.
Regardless - thanks for the great module. It helps me in other places as well!
Right, in your case it's DNSRoutingEnabled, but for others, it may be a value from DisplayName, and for others value from FriendlyName. It's just something user dependant which means there needs to be a choice and the value needs to be unique. It can't assume things.
New versions resolve this issue:
1.21.0 - 2024.06.29
- Changed behavior of
TransposeinNew-HTMLTable/Out-HtmlView - Added
TransposeLegacytoNew-HTMLTable/Out-HtmlViewto keep old behavior - Added
TransposeNametoNew-HTMLTable/Out-HtmlViewto allow for custom name (default isObject 0,Object 1,Object 2) - Added
TransposePropertytoNew-HTMLTable/Out-HtmlViewto allow for transposing on unique value from specific property (ex. ServerName) - Added
Out-HtmlViewadditional optionsPrettifyObject, PrettifyObjectSeparator, PrettifyObjectDateTimeFormat
Those changes resolve: #316
$Object = @(
[PSCustomObject] @{
Test = 5
Ello = 'Motto'
Hello = 'Totto'
}
[PSCustomObject] @{
Test = 5
Ello = 'Motto'
Hello = 'Totto'
}
[PSCustomObject] @{
Test = 5
Ello = 'Motto'
Hello = 'Totto'
}
[PSCustomObject] @{
Test = 5
Ello = 'Motto'
Hello = 'Totto'
}
[PSCustomObject] @{
Test = 5
Ello = 'Motto'
Hello = 'Totto'
}
[PSCustomObject] @{
Test = 3
Ello = 'Lotto'
Hello = 'Totto'
}
)
$Object | Out-HtmlView -Transpose -TransposeName 'Test ' -Filtering
New-HTML -TitleText $Title -Online -FilePath $PSScriptRoot\Example-TableTranspose01.html {
New-HTMLTable -DataTable $Object -Filtering -Transpose
} -ShowHTML