New-UDTable int being nulled

Product: PowerShell Universal
Version: 1.5.19

New to PSU and having an issue presenting some information with New-UDTable.

I have a module that queries MS GraphAPI for Microsoft Sku details which outputs the below

ActiveUnits    NoteProperty int ActiveUnits=1000000                                
ConsumedUnits  NoteProperty int ConsumedUnits=4                                    
Date           NoteProperty datetime Date=15/06/2021 09:34:51                      
Services       NoteProperty string[] Services=System.String[]                      
SKUId          NoteProperty string SKUId=xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx     
SKUName        NoteProperty string SKUName=STREAM                                  
SuspendedUnits NoteProperty int SuspendedUnits=0                                   
TenantId       NoteProperty string TenantId=xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx   
WarningUnits   NoteProperty int WarningUnits=0   

I have this outputing to a dashboard which is mostly working except any fields with the value of 0 are being blanked out

$UDTable = New-UDTable -Data $SKU -Title 'Tenant SKU List' -ShowPagination -ShowSelection -Export -ShowSearch -showSort
$UDtable.Data[0]

SuspendedUnits :                                      
WarningUnits   : 
TenantId       : xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx 
SKUId          : xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx 
Services       : System.String[]                      
SKUName        : Stream
ConsumedUnits  : 4
ActiveUnits    :    1000000 

The workaround I have at the moment is to run a select-object expression to convert this to a string before the New-UDTable but trying to see if there is another way

 $Sku  | select-object SKUName,ActiveUnits,ConsumedUnits,@{Name='ActiveUnits';Expression={$_.ActiveUnits.toString() }},@{Name='Services';Expression={$_.Services -join ', '}}

This seems like an enhancement we need to make. I’m surprised this is the first I’ve heard about it. I’ll open an issue for this.

1 Like

Did hit another odd one with a different set of data, which out puts an appliance version number as a string.

If the UDTable has a column named ‘Version’ no data is displayed, change the column to ‘OSVersion’ data is displayed.

I have tried my workaround above but this issue presents differently as the new-udtable in PS7 does show the data it’s only in the web portal that the data is missing.

Back at my machine now so I can get the code

$healthDetails =  Get-CiscoESAHealth @paramGetCiscoESAHealth | Select-Object ESA,Version

        $columns = @(
            New-UDTableColumn -Property ESA -Title ESA -IncludeInExport -IncludeInSearch -DefaultSortColumn
            New-UDTableColumn -Property Version -Title OSVersion -IncludeInExport -IncludeInSearch
      
        )

            Show-UDModal -Content {
                New-UDTable -Data $healthDetails -Title 'HealthDetails' -ShowPagination -ShowSelection -Export -ShowSearch -Columns $columns
            }
        }

Having to split the post as I can only do 1 image at a time as a new user

But just renaming the property to OSVersion

$healthDetails =  Get-CiscoESAHealth @paramGetCiscoESAHealth | Select-Object ESA,@{name='OSVersion';expression={$_.Version}}

        $columns = @(
            New-UDTableColumn -Property ESA -Title ESA -IncludeInExport -IncludeInSearch -DefaultSortColumn
            New-UDTableColumn -Property OSVersion -Title OSVersion -IncludeInExport -IncludeInSearch
      
        )

            Show-UDModal -Content {
                New-UDTable -Data $healthDetails -Title 'HealthDetails' -ShowPagination -ShowSelection -Export -ShowSearch -Columns $columns
            }
        }

Doing some additional digging in the web developer panel (Admittedly I know nothing about this) I see the field name is missing

That’s very weird. I don’t know why it would fail to select the version property if the property is called version.

What is the output when you do a get member on that array of objects?

$healthDetails =  Get-CiscoESAHealth @paramGetCiscoESAHealth | Select-Object ESA,Version
$healthDetails | Get-Member

Nothing special, I had thought initially I had defined the data type as [version] but its just a plain old string.

Name                 MemberType   Definition                               
----                 ----------   ----------                               
Equals               Method       bool Equals(System.Object obj)           
GetHashCode          Method       int GetHashCode()                        
GetType              Method       type GetType()                           
ToString             Method       string ToString()                        
ActiveRecipients     NoteProperty long ActiveRecipients=7845               
CPU                  NoteProperty string CPU=13%                           
ESA                  NoteProperty string ESA=Hostname.domain.com
InboundConnections   NoteProperty long InboundConnections=7                
Memory               NoteProperty string Memory=16%                        
OutboundConnections  NoteProperty long OutboundConnections=2               
ResourceConservation NoteProperty long ResourceConservation=0              
Status               NoteProperty string Status=Online                     
Timestamp            NoteProperty datetime Timestamp=15/06/2021 15:40:35   
Uptime               NoteProperty timespan Uptime=21.02:45:18              
Version              NoteProperty string Version=13.x.x-123              
WorkQueue            NoteProperty long WorkQueue=0