Hi,
My UDgrid is returning a number rather than “running”:
New-UdColumn -Size 12 {
New-UdGrid -Title "Service" -Endpoint {
Get-Service | Select-Object name,DisplayName,Status | Out-UDGridData
}
}
Output of
Get-Service | Select-Object name,DisplayName,Status | Out-UDGridData
{
“Name”: “AarSvc_4fb90db”,
“DisplayName”: “Agent Activation Runtime_4fb90db”,
“Status”: 4
},
The below works correctly
Get-Service | Select-Object name,DisplayName,Status
Is there something odd with New-UdGrid or Out-UDGridData?
Get-Service | Out-UDGridData
Lags out and never ends
Same happens if you throw the output of invoke-SQL at it. Hmm
Hi Maylife,
The get-service returns an “number” for status, and powershell handles the beatification and makes it readable everytime you reference it.
Test the following command:
get-service -name wuauserv | select Name, Status | convertto-json
You can see that it stores the “status” as a number. Working solution is to do an foreach-object before piping it into Out-udgriddata
get-service -name wuauserv | select Name, Status | ForEach-Object {
[PSCustomObject]@{
Name = _.Name
Status = [string]_.Status
}
} | out-udgriddata
3 Likes
Hi Bosen29
Thank you for your quick and detailed reply it fully solved my issue.
It really helped me get my head around it.
I did some formatting, so in the case anyone else needs it:
New-UDColumn -Size 12 {
New-UDGrid -Title "Service" -Endpoint {
Get-Service | select Name, DisplayName, Status | ForEach-Object {
[PSCustomObject] @{
"Name" = $_.Name
"Display Name" = $_.DisplayName
"Status" = [string]$_.Status
}
} | Out-UDGridData
}
Thank you for your help
2 Likes