So I've an array-variable of servers that is dynamically created from an external script. I now need to populate my GUI form with a list of check-boxes for each server. This will work as a selection mechanism when doing deployments to said servers.
As I don't know how many servers are going to be in my list, this form will have to have the check-boxes created dynamically. The issue I'm having is setting parameters of these new variables, and adding to the form. I just don't get how I can force PS to expand my iterator variable within the checkbox variable name. Here's what I have currently, which will create my variables but not apply the updates to the parameters:
$form1.Text = "Server Selection"
$form1.Name = "form1"
$form1.DataBindings.DefaultDataSourceUpdateMode = 0
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Width = 235
$System_Drawing_Size.Height = 500
$form1.ClientSize = $System_Drawing_Size
$i = 0
$y = 0
$serverList | %{
New-Variable -Name "Checkbox$i" -value (New-Object System.Windows.Forms.CheckBox)
set-variable -name "Checkbox$i.VisualStyleBackColor" -value $true
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Width = 104
$System_Drawing_Size.Height = 24
$Checkbox{i}.Size = $System_Drawing_Size
$Checkbox{i}.TabIndex = $i
$Checkbox{i}.text = $_
$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 60
$System_Drawing_Point.Y = 21 + $y
$Checkbox{i}.Location = $System_Drawing_Point
$Checkbox{i}.DataBindings.DefaultDataSourceUpdateMode = 0
$Checkbox{i}.name = "server"
$y = $y + 20
$i++
$form1.Controls.Add($Checkbox{i})
}
Anyone know how I can do this expansion or assignment correctly?