Is there a way to Get-Variable from the $Cache scope?

Product: Universal Dashboard
Version: 2.9.0

I need to loop through variables inside the $Cache scope, but I can’t get them dynamically using Get-Variable:


$InternalVariables = @(

$InternalVariables | ForEach {
    $variable = (Get-Variable -name "$Cache:$($_)").Value

I need $variable to get the $Cache:Status, $Cache:Cleared and $Cache:Published values inside the loop. From what I’ve seen, it doesn’t work because $ is a wildcard (escaping doesn’t help). Also, it’s not possible to inform the $Cache scope using the -Scope parameter.

Is there a way to access these variables dynamically like this?

UD uses the IMemoryCache to store this info. You can access it directly here. It doesn’t support iterating over items.


Here is a strategy that some use to work around this:

Thank you very much, it worked perfectly