Good evening,
I am attempting to dynamically create a variable within an endpoint based on a CSV and then call the variable from the Dashboard.
The variable will be created at “New-Variable -Name “$($server.name)fullname” -Value $server.name” but must be added to the $Cache: scope so it can be called from New-UDParagraph -Text REFERENCE_TO_CACHED_VARIABLE.
How would I create a variable “$Server1fullname” and call “$Cache:Server1fullname”
$db = new-UDDashboard -Title "Dashboard 2.0" -Content {
New-udrow -Columns {
New-UDColumn -size 3 -Endpoint {
New-UDCard -id "test" -Title "test card" -BackgroundColor REFERENCE_TO_CACHED_VARIABLE -Endpoint {
New-UDParagraph -Text REFERENCE_TO_CACHED_VARIABLE
}
} -AutoRefresh -RefreshInterval 60
}
}
$Cache:BGpass = “#93ec71”
$Schedule_Server_Name = New-UDEndpointSchedule -Every 1 -Minute
$Endpoint_Server_Name = New-UDEndpoint -Schedule $Schedule_Server_Name -Endpoint {
$Masterlist = Import-Csv "C:\UniversalDashboard\ServerConfig.csv"
Remove-Variable -Name *background
Remove-Variable -Name *services
foreach ($server in $Masterlist) {
New-Variable -Name "$($server.name)fullname" -Value $server.name
New-Variable -Name "$($server.name)background" -Value $Cache:BGpass
}
}
Get-UDDashboard | Stop-UDDashboard
Start-UDDashboard -Dashboard $db -Port 10000 -Endpoint $Endpoint_Server_Name -AutoReload