Conditional formatting New-UDCard

And if you want to have a bit more control, you can step into the realm of CSS:

$Dashboard = New-UDDashboard -Title Services -Content {
    New-UDRow -Endpoint { 
        Get-Service | ForEach-Object {
            $BackgroundColor = '#B40404' #Red
            if ($_.Status -eq 'Running') {
                $BackgroundColor = '#088A29' #Green
            }

            New-UDElement -Tag 'div' -Content {
                New-UDElement -Tag 'h6' -Content {$_.Name}
                New-UDElement -Tag 'h4' -Content {$_.Status.tostring()}
            } -Attributes @{
                style = @{
                    backgroundColor = $BackgroundColor
                    color = 'white'
                    'min-height' = '100px'
                    width = '250px'
                    float = 'left'
                    margin = '5px'
                    display = 'inline-block'
                    'text-align' = 'center'
                }
            }
        } 
    } -AutoRefresh -RefreshInterval 60
}

Get-UDDashboard | where{$_.Port -eq 10000} | Stop-UDDashboard
Start-UDDashboard -Dashboard $Dashboard -Port 10000

2 Likes