Is it possible to increment count on variable objects in Powershell?
Example:
$var1 = "This"
$var2 = "Is"
$var3 = "A Test"
1..3 | ForEach-Object {$var$_ = DoSometing}
Reason I am asking this, is because I am creating a GUI with system.Windows.Forms.CheckBox
. I have several checkbox objects in variables that end with a number I want to manipulate.
$Checkbox1
$Checkbox2
$Checkbox3
$Checkbox4
I am wondering if there is a clean and good way to manipulate these objects with an Foreach-Object
. Instead of manipulating each object seperatly.