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:
Hi @franpola!
Welcome to the UD forums!
No question is too basic, thats what a forum is for man!
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.
#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 }
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.
The $local varaible, will not be avaliable to the endpoint of New-UDGrid for times at end.
See: https://docs.universaldashboard.io/concepts
Content vs Endpoint -> Endpoints are executed at siteload (IE variables defined outside of endpoints won’t be avaliable, whilst content is executed at startup.
#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 }
}
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?
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%