Missing content from Grid Output

Greetings, I am trying to get a list of installed features from a server remotely and outputting to a UDGrid. The script runs without error and produces content that can be seen in the Variable, but is never shows up on the grid. Funny thing is that there is a Next/Previous button that shows up at the bottom of the page. It’[s like the content is there…just invisible.

Here’s the code:

$Page2 = New-UDPage -Name “Features and Software” -Icon windows -Content {
New-UDGrid -Title “Installed Features” -Headers @(“Installed_Features”) -Properties @(“Installed_Features”) -Endpoint { $SFeature | Out-UDGridData } -FontColor Black

I can’t speak as to why this is the case but I had some empty columns and did the following to get it to render the string in a grid, the .ToString() seemed to do it.

                DisplayName = $_.DisplayName.ToString().Trim()
                Status = $_.Status.ToString()

So the full block looked something like:

New-UdGrid -Title “Services” -Headers @(“DisplayName”, “Status”) -Properties @(“DisplayName”, “Status”) -AutoRefresh -RefreshInterval 60 -Endpoint {
$Services = Get-Service -ComputerName $ComputerName
$Services | Foreach-Object {
DisplayName = $.DisplayName.ToString().Trim()
Status = $
} | Out-UDGridData

1 Like

Hey … That worked Perfectly. Thanks Much!!

1 Like

Tried adding " $SFeature | Select-Object Installed_Features | Out-UDGridData" ?
I have experienced similar issue and had to select the properties I export to the grid.

In general, casting to string is a safer practice than using the .ToString() method, as .ToString() will throw an error if the variable value is $Null.
When trimming is required, throw in a couple parenthesis to override the order of operations.

Get-Service |
    Select-Object -Properties @(
        @{ Label = 'DisplayName'; Expression = @{ ([string]$_.DisplayName).Trim() } }
        @{ Label = 'Status'     ; Expression = @{  [string]$_.Status } } )

Tim Curwick

1 Like