I am creating a new variable name by combining existing variables, however, I cannot find a way to reference the new variable names dynamically through using my existing variables.
$count = 1
New-Variable -Name "Jobname$Count"
I am expecting to get "Jobname1" when I resolve dynamically with $JobName$Count.
I have tried different combinations of referencing the variable but none of them worked:
$JobName$($Count)
$JobName"$Count"
$JobName"$($Count)"
$JobName"($Count)"
How can I achieve this?
$jobName1. I assume you want to dynamically call it and get it's value?Get-Variable -Name "$Jobname$count"?