I created 4 objects, where Context = "App_Name" And I'm trying to create a variable, and then use it, but I don't know beforehand which name this variable will have, because it depends on which object is used right now.
With what I have below, I can list the name of the variable, but my question is how to call one of them, the one of the on-going object.
Like if object context is "paint", calling $list_of_paint without knowing this name.
Something like $$VarName (which doesn't work, but so you can see the logic)
[System.Collections.ArrayList]$ndf = @()
$test = "2"
$VarName = "list_of_" + $obj.context
New-variable -Name $VarName -value "$test" -Force | ForEach-Object $ndf.add("$" + "$VarName)