I am trying to create a very simple array of values. From a PS C:\> everything works as expected. But as soon as I use a script, the arrays start to misbehave. Instead of creating new array of elements, I am just getting a single concatenated string. What as I doing wrong?
The += operator behavior depends on what's on the left side. Your $a variable is originally declared as a string, not an array, so you get string concat behavior. Declaring it as an array will change that behavior: