Dashboard with info from remote servers


I am kind of new to this so, sorry if the question is too basic. I have little project where i would like to show on a dashboard the information about windows updates pending to be installed on a series of Servers.

So far I am able to retrieve the a list of the pending updates of any server using this code:

$session = New-PSSession -ComputerName RemoteServer
Invoke-Command -Session $session -ScriptBlock { $updlist = Get-WUList | Select-Object -Property Title -ExcludeProperty RunspaceId }
$Local = Invoke-Command -Session $session -ScriptBlock { $updlist }

So my question is, how can i show this information on the Dashboard ?


Hi @franpola!
Welcome to the UD forums!
No question is too basic, thats what a forum is for man! :slight_smile:

Regarding your question:
This code can run wherever you want inside an endpoint. To present, there are a few options: including UDTable and UDGrid.
I’d go with the UDGrid.

Check out
and feel free to shout if you need any guidance with it :slight_smile:

Quick question: why do you do a double?

$local = Invoke-Command -Session $session -ScriptBlock { Get-WUList | Select-Object -Property Title -ExcludeProperty RunspaceId }

This should work i believe.

Hi @BoSen29!

Thanks for the welcome.
I was able to display the results using the UDGrid command which is great.

Now the script loos like this, however when i run the script on ISE it takes about 2 minutes to complete, i dont know why?

#creates ps session with remote servers
$session = New-PSSession -ComputerName WINMSSQL

#gets the list of available updates from remote server into a variable
Invoke-Command -Session $session -ScriptBlock { $updlist = Get-WUList | Select-Object -Property Title -ExcludeProperty RunspaceId }

#passes the results of the previous remote machine variable into a local variable
$Local = Invoke-Command -Session $session -ScriptBlock { $updlist }

#shows list
$dashboard = New-UDDashboard -Title “test” -Content {
New-UDGrid -Title “Updates” -Endpoint { $Local | Select-Object -Property Title, PSComputerName -ExcludeProperty RunspaceId | Out-UDGridData }
Start-UDDashboard -Port 10001 -Dashboard $dashboard

The question about the double, its because the results of the invoke command that runs on the remote computer are saved into $udplist and then stored into $Local which is in the local computer and can then be used on the dashboard.

Thanks so much!

Hi agian @franpola
Looks good !

The $local varaible, will not be avaliable to the endpoint of New-UDGrid for times at end.
Content vs Endpoint -> Endpoints are executed at siteload (IE variables defined outside of endpoints won’t be avaliable, whilst content is executed at startup.

What i would do, is create a scheduled endpoint:
to collect the relevant data, and then store it in the $cache variable:
Which is avaliable to all the endpoints.

Regarding the double, shouldn’t my previous suggestion work? As you’d just pipe the output through to the var?

$local = Invoke-Command -Session $session -ScriptBlock { Get-WUList | Select-Object -Property Title -ExcludeProperty RunspaceId }

Would reduce the exectuiontime of the code, depending on the latency of the page.

1 Like

Hi @BoSen29

It seems to work also ok with your suggestion , this is how it looks now…

$session = New-PSSession -ComputerName WINMSSQL
$Schedule = New-UDEndpointSchedule -Every 1 -Hour

#Task that gets the number of available modules every hour and saves it to the cache
$EveryHour = New-UDEndpoint -Schedule $Schedule -Endpoint {
$Cache:Updates = Invoke-Command -Session $session -ScriptBlock { Get-WUList | Select-Object -Property Title -ExcludeProperty RunspaceId }

$dashboard = New-UDDashboard -Title “Test” -Content {
New-UDGrid -Title “Updates” -Endpoint {
$Cache:Updates | Select-Object -Property Title, PSComputerName -ExcludeProperty RunspaceId | Out-UDGridData

Start-UDDashboard -Port 10001 -Endpoint $EveryHour -Dashboard $dashboard

How would i go if wanted to show the same info from a few more servers? Let´s say have an overview page and then click on a server to view the details?


Replace the code above with:

$Schedule = New-UDEndpointSchedule -Every 1 -Hour
$EveryHour = New-UDEndpoint -Schedule $Schedule -Endpoint {
     $Cache:Updates = Invoke-Command -ComputerName @("server1", "server2") -Scriptblock { Get- 
      WUList | Select-Object -Property Title -ExcludeProperty RunspaceId }

Should work as long as all the servers accept the credentials that is running UD.
If you need to start a remote session for each server, store them in an array and just foreach them
New-Session them
Then invoke command
and then remove the session.

Note: always close your sessions, and if you’re planning on using your sessions across endpoints, make sure to store the relevant session in the $cache or $session variable.
ie : $Cache:CurrentSession = New-PSSession -Computername %somecomputer%

Happy hunting! :slight_smile: