Can you have multiple outputs for a single input?

I am working on a dashboard where I have an input for the user to enter a server name. Then i want to run multiple checks in the back in background that connect to that server and get different stats.

I want to have a 4 column row that returns 4 items then under neath that 2 columns that return 2 items. Here is a sample. anything after the 4 column layout doesnt seem to run.

any help would be appreciated.
thanks,

New-UDInput -Title “Enter Server Name” -Endpoint {
param(
[string]$RemoteComp
)

New-UDInputAction -Content {
New-UDLayout  -Columns 4 {
New-UDCard -title 'Server Name' -Endpoint {$RemoteComp}
New-UDCard -title 'System Time'-Endpoint {Invoke-Command -ComputerName $RemoteComp - ScriptBlock { get-date }} 
New-UDCard -title 'Uptime' -Endpoint {Invoke-Command -ComputerName $RemoteComp -ScriptBlock { Format-Table | systeminfo | find "System Boot Time" }}
New-UDCard -title 'Operating System' -Endpoint {(Get-WmiObject -ComputerName $RemoteComp Win32_OperatingSystem).Caption}
}

New-UDMonitor -Type Line -Title "CPU" -RefreshInterval 1 -DataPointHistory 100 -Endpoint {
Get-Random | Out-UDMonitorData
}

}#close input action

}#close input

Hi Gerard, just put a new-udelement as first level element to group everything under the same roof.

Something like :

New-UDInput -Title "Enter Server Name" -Endpoint {
    param(
        [string]$RemoteComp
    )
    New-UDInputAction -Content {
        New-UDElement -Tag 'div'  -Content {
            # your layout
           
            # your monitor
        }
    }#close input action
}

By doing that, you are basically outputing one component, the new-udElement, which contains your multiples output.

You can use New-UDCard or any other single component as top-level component but New-UDElement -Tag 'div' -Content {...} have the advantage of being completely transparent when rendered.

Complete example.
  New-UDInput -Title "Enter Server Name" -Endpoint {
        param(
            [string]$RemoteComp
        )
        New-UDInputAction -Content {
            New-UDElement -Tag 'div'  -Content {
                New-UDLayout  -Columns 4 {
                    New-UDCard -title 'Server Name' -Endpoint { $RemoteComp }
                    New-UDCard -title 'System Time'-Endpoint { Invoke-Command -ComputerName $RemoteComp - ScriptBlock { get-date } } 
                     New-UDCard -title 'Uptime' -Endpoint { Invoke-Command -ComputerName $RemoteComp -ScriptBlock { Format-Table | systeminfo | find "System Boot Time" } }
                    New-UDCard -title 'Operating System' -Endpoint { (Get-WmiObject -ComputerName $RemoteComp Win32_OperatingSystem).Caption }
                }

                New-UDMonitor -Type Line -Title "CPU" -RefreshInterval 1 -DataPointHistory 100 -Endpoint {
                    Get-Random | Out-UDMonitorData
                }
            }
        }#close input action
}
1 Like

Awesome. Thank you so much. Thats exactly what i needed.

I dont know if i should post this as a new topic but some of the invoke-commands that i run dont seem to work. For example if i try to pull the last 10 application log events using this command:

New-UDCard -title ‘Application Log Errors’ -Endpoint {Invoke-Command -ComputerName $RemoteComp -ScriptBlock{Get-EventLog -LogName Application -Newest 10}}

i always get these react errors. Is it my formatting or just some commands dont work?
Thanks again.

Minified React error #31; visit https://reactjs.org/docs/error-decoder.html?invariant=31&args[]=object%20with%20keys%20{}&args[]= for the full message or use the non-minified dev environment for full errors and additional helpful warnings.

That sounds like it’s because Get-EventLog returns an object array, which New-UDCard doesn’t know how to display. If you did something like (Get-EventLog -LogName Application -Newest 10).Message inside your scriptblock, that should work.

Ideally when displaying arrays of objects like this, you’ll want to use either a New-UDTable or a New-UDGrid. The associated output cmdlets (Out-UDTableData and Out-UDGridData) are able to parse the object properties into a displayable format.

Good luck!

When you use the new-udtable or new-udgrid it wants you to use headers. Do those headers need to match the column names from when you run the command

i put this command in the endpoint and im still not getting anything back.

New-UDTable -Title ‘System Logs’ -Headers @(“index”, “time”,“entrytype”, “source”,“instanceID”, “message”) -Endpoint { Invoke-Command -ScriptBlock { Get-EventLog -ComputerName $RemoteComp -LogName System -Newest 10 }} | Out-UDTableData -Property @(“index”, “time”,“entrytype”, “source”,“instanceID”, “message”)

I apologize. I am new with scripting and clearly not getting it that easy.

Hey @gerard there is good documentation here:-
https://docs.universaldashboard.io/components/grids
Your headers is what is actually displayed in the grid the properties must match those of the object you are passing to the grid.