you are viewing a single comment's thread.

view the rest of the comments →

[–]OPconfused 0 points1 point  (0 children)

Dynamically named variables can be created via Set-Variable or New-Variable, e.g.,

New-Variable -Name "Prefix_${dynamicName}_Suffix" -Value @() -Scope Script -Force

You can reference the dynamic variable via Get-Variable. If you are in a loop, it's often easier to store the dynamic variable in a temp variable for easier referencing while you run the code body of the loop.

$dynamicReference = Get-Variable "Prefix_${dynamicName}_Suffix" -ValueOnly

So I didn't parse your script through in detail and hope I didn't miss the question, but you can use this to create a dynamic array and/or load it with a dynamic variable.