I am trying to run an endpoint on remote servers to bring back updates information.
I then put the contents of updates into a page with a table.
I can never get the table to fill with data.
Please help me figure this out. UD is such an awesome product.
Code below:
#. (Join-Path $PSScriptRoot "utils2.ps1")
function Cache-Updates {
param (
[String[]] $Servers
)
ForEach ($Server in $Servers) {
$Cache:Updates += Invoke-Command -ComputerName $Server -Script {ipmo PSWindowsUpdate; Get-WUList -MicrosoftUpdate}
}
Write-UDLog -Message "---------------------------CACHED UPDATES $Server---------------------------"
#Write-UDLog $AllUpdates
}
function New-UDServerPage {
param(
$Server
)
New-UDPage -Name $Server -Content {
New-UDElement -Tag div -Attributes @{ style = @{ paddingLeft = "20px" }} -Endpoint {
$Updates = $Cache:Updates | where { $_.ComputerName -eq "$Server" }
$updatecount = $Updates.count
New-UDTable -Title "Updates not installed for $Server. There are: $updatecount" -Headers @("Update Title", "KB", "Severity", "Size") -Endpoint {
$Updates | ForEach-Object {
[PSCustomObject]@{
title = $_.title
kb = $_.kb
severity = "None"
size = $_.size
}
} | Out-UDTableData -Property @("title", "kb", "severity", "size")
} -AutoRefresh -RefreshInterval 10
}
}
} # end of function
$Pages = @()
$Pages += . (Join-Path $PSScriptRoot "\home.ps1")
$serverNav = @()
$servers = @('SERVER01',
'SERVER02',
'SERVER03')
$EI = New-UDEndpointInitialization -Function Cache-Updates
$Schedule30 = New-UDEndpointSchedule -Every 5 -Minute
$EndpointUpdates = New-UDEndpoint -Endpoint {
$Cache:Updates = Cache-Updates $servers
}
$servers | ForEach-Object {
$page = New-UDServerPage -Server $_
$serverNav += New-UDSideNavItem -Text $_ -Url $_
$Pages += $Page
}
$Navigation = New-UDSideNav -Content {
New-UDSideNavItem -Text "Home" -Url "Home" -Icon home
$serverNav
} -Fixed
New-UDDashboard -Title "Outstanding Windows Updates for servers" -Pages $Pages -Navigation $Navigation -EndpointInitialization $EI