My goal is to create and assign a value to a variable used for background color of a UD-Card’s -BackgroundColor parameter and store the variable to the $Cache scope. This work will be done in an endpoint and the result will need to be cached.
A list of server names is stored in $ServerList.
End Goal -
Have a variable named “$Cache:Server1background” with value of $BGpass
Have a variable named “$Cache:Server2background” with value of $BGpass
Have a variable named “$Cache:Server3background” with value of $BGpass
A quick test with my server names raises the issue of illegal characters in variable names. My resulting variable from "New-Variable -Name “$($server.name)background” -Value Cache:BGpass" is {asdf-asdfbackground}. The curly braces are added by powershell automatically.
Valid characters are only letters, numbers and underscore.
Interesting. It works with a self contained scenario as above in a test page. It’s not working with cache variables set in a scheduled endpoint on my live dashboard.
I can call the cache:vars explicitly in debug but not be assembling the variable name from an array.
I’ll experiment.