Out-UDGridData with Function?

I’ve been struggling to get Universal Dashboard to accept any function as valid endpoint input. I have formatted objects being returned in my functions but UD doesn’t seem to be able to read the data.

$Dashboard = New-UDDashboard -Title "Test" -Content {
    New-UDRow -Columns {

        New-UDColumn -SmallSize 4 -Content {
            New-UDGrid -Title "test" -Endpoint {Get-SQLInfo  | select-object "MachineName","MissingUpdates","LastCommTime" | Out-UDGridData }

Start-UDDashboard -Dashboard $Dashboard -Port 10005

Here’s some sample data returned from my function call

MachineName : Device01
MissingUpdates : 1
LastCommTime : 5/18/2020 4:51:49 PM

This is all my dashboard returns

Results of “return $result | gm | ft | clip” at the end of my function:
TypeName: System.Data.DataRow

Name MemberType Definition

AcceptChanges Method void AcceptChanges()
BeginEdit Method void BeginEdit()
CancelEdit Method void CancelEdit()
ClearErrors Method void ClearErrors()
Delete Method void Delete()
EndEdit Method void EndEdit()
Equals Method bool Equals(System.Object obj)
GetChildRows Method System.Data.DataRow[] GetChildRows(string relationName), System.Data.DataRow[] GetChildRows(string relationName, System.Data.DataRowVersion version), System.D…
GetColumnError Method string GetColumnError(int columnIndex), string GetColumnError(string columnName), string GetColumnError(System.Data.DataColumn column)
GetColumnsInError Method System.Data.DataColumn[] GetColumnsInError()
GetHashCode Method int GetHashCode()
GetParentRow Method System.Data.DataRow GetParentRow(string relationName), System.Data.DataRow GetParentRow(string relationName, System.Data.DataRowVersion version), System.Data…
GetParentRows Method System.Data.DataRow[] GetParentRows(string relationName), System.Data.DataRow[] GetParentRows(string relationName, System.Data.DataRowVersion version), System…
GetType Method type GetType()
HasVersion Method bool HasVersion(System.Data.DataRowVersion version)
IsNull Method bool IsNull(int columnIndex), bool IsNull(string columnName), bool IsNull(System.Data.DataColumn column), bool IsNull(System.Data.DataColumn column, System.Da…
RejectChanges Method void RejectChanges()
SetAdded Method void SetAdded()
SetColumnError Method void SetColumnError(int columnIndex, string error), void SetColumnError(string columnName, string error), void SetColumnError(System.Data.DataColumn column, s…
SetModified Method void SetModified()
SetParentRow Method void SetParentRow(System.Data.DataRow parentRow), void SetParentRow(System.Data.DataRow parentRow, System.Data.DataRelation relation)
ToString Method string ToString()
Item ParameterizedProperty System.Object Item(int columnIndex) {get;set;}, System.Object Item(string columnName) {get;set;}, System.Object Item(System.Data.DataColumn column) {get;set;}…
LastCommTime Property datetime LastCommTime {get;set;}
MachineName Property string MachineName {get;set;}
MissingUpdates Property int MissingUpdates {get;set;}

Hi @eferreira2,

Weird :-/

Could you try with the same data, just as static pscustomobject?
If that doesn’t work, could you try to specify the Properties and Headers for the grid.

If that works, try to convert the DataRow to a PScustomobject.

If none of these works… shout!

I used a custom PSObject in my function:
ForEach ($item in $result) {

$return = New-Object -TypeName PSObject -Property @{

'MachineName' = $item.MachineName
'MissingUpdates' = $item.MissingUpdates
'LastCommTime' = $item.LastCommTime

return $return

Adding headers actually breaks the grid completely with a " Cannot read property ‘0’ of null" error. I’m not sure where that’s coming from.

New-UDGrid -Title “test” -Headers @(“MachineName”,“MissingUpdates”,“LastCommTime”) -Endpoint {Get-eDistInfo | Out-UDGridData }

The 3 items I’m trying to display are of regular variable types:

TypeName : System.Management.Automation.PSCustomObject
Name : LastCommTime
MemberType : NoteProperty
Definition : datetime LastCommTime=5/18/2020 6:00:20 PM

TypeName : System.Management.Automation.PSCustomObject
Name : MachineName
MemberType : NoteProperty
Definition : string MachineName=Device01

TypeName : System.Management.Automation.PSCustomObject
Name : MissingUpdates
MemberType : NoteProperty
Definition : int MissingUpdates=1

Hi @eferreira2,

Do you have any other grids working in your UD?
Did you include your function ‘Get-SQLInfo’ in your endpointinitalization?
Try specifying both Header and Properties to your UDGrid.

If that doesn’t work, try having an static pscustom object inside your grid?

Any clientside errors in the browser console?

After exhausting all troubleshooting options, I’m unfortunately going to have to give up on Universal Dashboard. It looks like my project ends here.

@eferreira2 dude, don’t be a quitter, I am using SQL with UD and it works great. :grinning:
Please before making the final decision to pass up an amazing bit of software that can seriously make your scripts so much more interactive have a read of:-

Dude I am so commited, I’d even provide you with a basic SQL dashboard to show you how amazing UD is with SQL for FREE I love this software!

if you try the following
New-UdGrid -Title “Processes” -Endpoint {
Get-Process | Select Name,ID,WorkingSet,CPU | Out-UDGridData
and it works then UD is working as expected, at this point you need to look into your function code.
maybe if you can post your function code we can tell you what the issue is.
i have been using UD to automate db backup and restore and execute sql queries and request info and it works with no problem, i have tested UD with sqlserver module and dbatools module and aws modules with no issues.
Am currently even running UD with PS 7.1 and its working flawlessly.
As you can see am using different technologies with UD and it just works.

By the way this also might help in your issue, in your function do not use format-table (ft) this is maybe what is breaking your output,try to test your function just with simple data output do not use format or anything.

I was actually able to figure this out at the 11th hour. I appreciate the input received. For anyone else struggling here are the key things I learned…

Use Invoke-SQLCMD2 module for all SQL querying. I first used DBATools but the way they format objects messes with UD’s ability to parse data. Invoke-SQLCMD I found had issues with multiple SQL queries running simultaneously.

This is the syntax I used in my parsing of data:
$result = Invoke-SQLCMD2 -ServerInstance $SQLServer -Credential $sqlcred -database $db -Query $query

$object = @(foreach ($res in $result) {

New-Object -Type PSObject -Property @{
    'Device'   = $res.MachineName
    'Updates' = $res.MissingUpdates
    'Last Check-In' = $res.LastCommTime

return $object
1 Like

UD has save me a lot of time and effort with Active directory and you can get a lot of help here.