Tables that have column rendering not working with PowerShell 5.1 after 3.5.0

So I have several dashboards that have column rendering running under PowerShell 5.1. The same code works if I uninstall and go back to a version of Universal pre 3.5.0 and run the same dashboard code. To try and track down where the issue was I took one of the example tables in the documentation and added a render column.

    $Data = try { get-service -ea Stop | select Name,@{n = "Status";e={ $_.Status.ToString()}},@{n = "StartupType";e={ $_.StartupType.ToString()}},@{n = "StartType";e={ $_.StartType.ToString()}} } catch {}
    $Columns = @(
        New-UDTableColumn -Property Name -Title "Service Name" -ShowSort -IncludeInExport -IncludeInSearch -ShowFilter -FilterType text
        New-UDTableColumn -Property Status -Title Status -ShowSort -DefaultSortColumn -IncludeInExport -IncludeInSearch -ShowFilter -FilterType select 
        New-UDTableColumn -Property StartupType -Title StartupType -IncludeInExport -ShowFilter -FilterType select -Render {
            New-UDButton -Id "btn$($EventData.StartupType)" -Text "StartupType!" -OnClick { Show-UDToast -Message $EventData.StartupType } 
        }       
        New-UDTableColumn -Property StartType -Title StartType -IncludeInExport -ShowFilter -FilterType select 
    )
    New-UDTable -Id 'service_table' -Data $Data -Columns $Columns -Title 'Services' -ShowSearch -ShowPagination -ShowSelection -Dense -OnRowSelection {
        $Item = $EventData
        Show-UDToast -Message "$($Item | out-string)"
    }
    New-UDButton -Text "GET Rows" -OnClick {
        $value = Get-UDElement -Id "service_table"
        Show-UDToast -Message "$( $value.selectedRows | Out-String )"
    }

This is the error in the logs (x200).

Exception calling “GetNewClosure” with “0” argument(s): “The attribute cannot be added because variable DefaultSortDirection with value would no longer be valid.”
You cannot call a method on a null-valued expression.

If I switch it to use PowerShell 7.1 then it works without issue. Any ideas?

Product: PowerShell Universal
Version: 3.5.4
1 Like

I’m also seeing this in 3.5.5 under PS 5.1 when using -Render on New-UDTable, and I can’t flip it to PS 7 as it’s a server VM running on Server 2016 and makes use of the ActiveDirectory module; if I try to do it I get a Exception calling "GetSteppablePipeline" with "1" argument(s): "The parameter is incorrect." immediately on loading the dashboard.

Kind of stuck between a rock and a hard place with this one. @adam , is there an issue open for this already? Seems we can’t currently make use of -Render under these conditions with 3.5.4/3.5.5.

For anyone that runs into this issue, we have a fix for it and it will be included in 3.5.6 after we validate it solves the issue for everyone. It’s currently in our nightly builds.

1 Like